简体   繁体   English

Node.js-启动命令使节点崩溃,但是index.js运行正常

[英]Node.js - start command crashing node, but index.js running fine

I have a node.js package where the index.js file works as expected. 我有一个node.js包,其中的index.js文件按预期工作。

But when I call 但是当我打电话

npm start

It crashes with the following error: 它崩溃并显示以下错误:

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

I've checked the package.json file. 我已经检查了package.json文件。 No comments. 没意见。 No errors as far as I can see. 据我所见,没有错误。 Here it is: 这里是:

{
  "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"
  },
}

Even if I remove the start line from the json and run npm start it still crashes with the error at the top. 即使我从json中删除了起始行并运行npm start它仍然会崩溃,并显示顶部错误。

Any thoughts? 有什么想法吗?

Check your error dude, it says that it can't parse your package.json, which is right: 检查您的错误消息,提示它无法解析您的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"
  },
}

The comma on the line before the last line makes your package.json file invalid. 最后一行之前的逗号使您的package.json文件无效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM