当我尝试使用npm install -g cordova
安装Cordova时出现此错误(请参阅帖子底部)。
我有Windows 7,64位。
几年前我尝试过安装phonegap,也许在我的系统中还有一些旧的模糊?
如果我写npm rm -g phonegap
错误:
C:\>npm install -g cordova
npm WARN engine npm@1.3.4: wanted: {"node":">=0.6","npm":"1"} (current: {"node":
"0.12.0","npm":"2.5.1"})
npm WARN engine cordova-js@3.8.0: wanted: {"node":"~0.10.x"} (current: {"node":"
0.12.0","npm":"2.5.1"})
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs
\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "cordova"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! file C:\Users\Eirik\AppData\Roaming\npm-cache\underscore\1.2.1\package\
package.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! Unexpected token
npm ERR! File: C:\Users\Eirik\AppData\Roaming\npm-cache\underscore\1.2.1\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
答案 0 :(得分:1)
此问题可能源于NodeJs。只需remove Node js completely和update with latest。
安装最新的NodeJS后再次尝试npm install -g cordova
。