在向dev-dependencies添加grunt时无法解析json

时间:2014-05-08 08:52:24

标签: node.js gruntjs npm

我有一个简单的package.json,我正在尝试将grunt添加到我的项目中。我已多次这样做,但从未遇到过这个问题

我的package.json

{
  "name": "express-todo",
  "main": "server.js",
  "dependencies": {
    "body-parser": "^1.0.2",
    "express": "^4.1.1",
    "jade": "^1.3.1",
    "mongoose": "^3.8.8",
    "nodemon": "^1.0.17",
    "request": "^2.34.0"
  }
}

然后从命令行我得到错误:

$ npm install grunt --save-dev
npm WARN package.json express-todo@ No repository field.
npm http GET https://registry.npmjs.org/grunt
npm http 304 https://registry.npmjs.org/grunt
npm ERR! Failed to parse json
npm ERR! Unexpected end of input
npm ERR! File: /home/jasonshark/.npm/grunt/0.4.4/package/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! System Linux 3.2.0-61-generic-pae
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "grunt" "--save-dev"
npm ERR! cwd /home/jasonshark/Projects/express-todo
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! file /home/jasonshark/.npm/grunt/0.4.4/package/package.json
npm ERR! code EJSONPARSE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/jasonshark/Projects/express-todo/npm-debug.log
npm ERR! not ok code 0

1 个答案:

答案 0 :(得分:8)

我只需要{p> npm cache clean