与cordova项目的npm版本有关的问题
我正在研究cordova项目。 在我的项目目录中,如果我键入:
node -v
我得到v6.11.1
npm -v
我得到3.10.10
有时,在项目中添加一个新的插件(例如cordova-plugin-statusbar
)后,发生这种情况的时候,我得到这个错误:
Discovered plugin "cordova-plugin-statusbar" in config.xml. Adding it to the project Failed to restore plugin "cordova-plugin-statusbar" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin cordova-plugin-statusbar@^2.2.3 via registry. Probably this is either a connection problem, or plugin spec is incorrect. Check your connection and plugin name/version/URL. ... ... npm ERR! Darwin 16.7.0 npm ERR! argv "/Users/myuser/.nvm/versions/node/v6.11.1/bin/node" "/Users/myuser/myprojectfolder/node_modules/.bin/npm" "install" "cordova-plugin-statusbar@^2.2.3" npm ERR! node v6.11.1 npm ERR! npm v2.15.12 npm ERR! code EPEERINVALID
所以npm版本与上面的不同。
插件获取的问题可以链接到检测到的版本中的这种差异? 为什么发生这种情况?
EPEERINVALID
意味着某些软件包已经过期,您必须使用-g
更新全局文件:
npm更新-g
否则你可以尝试重新安装cordova
和npm
:
npm卸载-g cordova
npm卸载
npm安装
npm install -g cordova
否则,如果你使用nvm
呢? 因为如果有两个不同版本的npm
则可能是在调用nvm
时必须更新npm
。