简体   繁体   中英

EJSONPARSE error with npm when trying to install a package

When I try to install an npm package after running npm init, I am am met with this response.

C:\Users\User\My Documents\brackets\2007webpackes6>npm install --save-dev babel-core
npm WARN package.json 2007webpackes6@1.0.0 No description
npm WARN package.json 2007webpackes6@1.0.0 No repository field.
npm WARN package.json 2007webpackes6@1.0.0 No README data
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save-dev" "babel-core"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! file C:\Users\User\AppData\Roaming\npm-cache\babel-runtime\6.9.2\package\package.json
npm ERR! code EJSONPARSE

npm ERR! Failed to parse json
npm ERR! No data, empty input at 1:1
npm ERR!
npm ERR! ^
npm ERR! File: C:\Users\User\AppData\Roaming\npm-cache\babel-runtime\6.9.2\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! Please include the following file with any support request:
npm ERR!     C:\Users\User\My Documents\brackets\2007webpackes6\npm-debug.log

The error report is telling that there is no data in the "package.json" but it's there when I open the file.

Package.json:

{
  "name": "2007webpackes6",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

Any help would be much appreciated.

I had the same issue just today. I used the git bash. When I tried it with the windows cmd it worked just fine. Now this doesn't tell you why the error is occurring but maybe it will get it working.

我在尝试安装Cordova时遇到了相同的错误,请尝试“清理npm缓存”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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