我在安装后尝试启动 NPM,但启动出错。
我在“package.json”文件中找不到语法错误 我找不到错误日志 我试过重新安装 我尝试清除缓存 都没有成功
这是我的“package.json”文件:
{
"name": "git-test",
"version": "1.0.0",
"description": "test json file",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"lite-server": "^2.4.0"
},
"scripts": {
"start": "npm run lite"
"test": "echo \"Error: no test specified\" && exit 1"
"dev": "lite-server"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools.git"
},
"author": "Master-Hippo",
"license": "ISC",
"bugs": {
"url": "https://github.com/Master-Hippo/Front-
End_Web_UI_Frameworks_and_Tools/issues"
},
"homepage": "https://github.com/Master-Hippo/Front-
End_Web_UI_Frameworks_and_Tools#readme"
错误日志如下:
npm ERR! code EJSONPARSE
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected string in JSON at position 228 while parsing
'{
npm ERR! JSON.parse "name": "git-test",
npm ERR! JSON.parse "version": "1.'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
而且,尽管消息说在特定文件夹中创建了错误日志,但该文件夹中实际上不存在错误日志。
我该如何解决这个问题?
最佳答案
尝试使用 jsonlint 验证您的 package.json
我猜你的文件可能是这样的:
{
"name": "git-test",
"version": "1.0.0",
"description": "test json file",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"lite-server": "^2.4.0"
},
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "lite-server"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools.git"
},
"author": "Master-Hippo",
"license": "ISC",
"bugs": {
"url ": "https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools/issues"
},
"homepage": "https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools#readme"
}
关于javascript - 如何修复 "Npm ERR! JSON.parse Unexpected string in JSON at position 228..",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56228659/