【问题标题】:Problems with npm versions of cordova project科尔多瓦项目的 npm 版本的问题
【发布时间】:2018-01-30 13:34:05
【问题描述】:

我正在从事一个 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版本和上面的不一样。

插件获取的问题是否与检测到的版本差异有关? 为什么会这样?

【问题讨论】:

    标签: node.js cordova npm


    【解决方案1】:

    EPEERINVALID 表示某些包已过时,您必须使用-g 更新全局:

    npm 更新 -g

    否则你可以尝试重新安装cordovanpm

    npm 卸载 -g 科尔多瓦

    npm 卸载

    npm 安装

    npm install -g 科尔多瓦

    如果你也使用nvm 吗?因为如果有 2 个不同版本的 npm,则可能需要在调用 nvm 时更新 npm

    【讨论】:

      猜你喜欢
      • 2017-09-27
      • 1970-01-01
      • 2017-01-11
      • 2014-04-23
      • 2014-12-29
      • 2016-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多