2016-10-19 97 views
0

我有一個node.js包,其中index.js文件按預期工作。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它仍然在頂部的錯誤崩潰。

有什麼想法?

+1

也許你的意思是'npm start'? – MustSeeMelons

+0

你是對的。雖然仍然有錯誤。更新了帖子以反映這一點。 @MustSeeMelons – Niazipan

+3

刪除依賴塊後的尾隨逗號? – ste2425

回答

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文件失效前行的逗號。