我有一个node.js包,其中index.js文件按预期工作。
但是当我打电话时
npm start
崩溃时出现以下错误:
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v4.6.0
npm ERR! npm v2.15.9
npm ERR! file /Users/martin.mcallister/Documents/leftovers/package.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! Trailing comma in object at 24:1
npm ERR! }
npm ERR! ^
npm ERR! File: /Users/martin.mcallister/Documents/leftovers/package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse
npm ERR! Please include the following file with any support request:
npm ERR! /Users/martin.mcallister/Documents/leftovers/npm-debug.log
我检查了package.json文件。没意见。就我所见,没有错误。这是:
{
"name": "leftovers",
"version": "1.0.0",
"description": "Use your leftovers",
"main": "index.js",
"scripts": {
"start" : "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/niazipan/leftovers.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/niazipan/leftovers/issues"
},
"homepage": "https://github.com/niazipan/leftovers#readme",
"dependencies": {
"body-parser": "^1.15.2",
"express": "^4.14.0"
},
}
即使我从json中删除了起始行并运行npm start
,它仍会因顶部的错误而崩溃。
有什么想法吗?
答案 0 :(得分:0)
检查你的错误老兄,它说它无法解析你的package.json,这是对的:
{
"name": "leftovers",
"version": "1.0.0",
"description": "Use your leftovers",
"main": "index.js",
"scripts": {
"start" : "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/niazipan/leftovers.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/niazipan/leftovers/issues"
},
"homepage": "https://github.com/niazipan/leftovers#readme",
"dependencies": {
"body-parser": "^1.15.2",
"express": "^4.14.0"
},
}
最后一行之前的行上的逗号会使您的package.json文件无效。