Cordova安装错误:path问题(?) – 错误代码ENOENT

在安装Xcode和NodeJS后,我现在试图安装Cordova,但是我得到以下有关缺less文件(错误的path?)的错误。

Luciens-MacBook-Pro:~ lucientavano$ npm cache clean Luciens-MacBook-Pro:~ lucientavano$ sudo npm install -g cordova Password: npm WARN deprecated npmconf@2.1.2: this package has been reintegrated into npm and is now out of date with respect to npm /usr/local/lib └── (empty) npm ERR! Darwin 15.3.0 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "cordova" npm ERR! node v4.2.6 npm ERR! npm v3.6.0 npm ERR! path /usr/local/lib/node_modules/.staging/abbrev-ef9cc920 npm ERR! code ENOENT npm ERR! errno -2 npm ERR! syscall rename npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/abbrev-ef9cc920' -> '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/abbrev' npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/abbrev-ef9cc920' -> '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/abbrev' npm ERR! enoent This is most likely not a problem with npm itself npm ERR! enoent and is related to npm not being able to find a file. npm ERR! enoent npm ERR! Please include the following file with any support request: npm ERR! /Users/lucientavano/npm-debug.log npm ERR! code 1 Luciens-MacBook-Pro:~ lucientavano$ tail -10 /Users/lucientavano/npm-debug.log 21365 error npm v3.6.0 21366 error path /usr/local/lib/node_modules/.staging/abbrev-ef9cc920 21367 error code ENOENT 21368 error errno -2 21369 error syscall rename 21370 error enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/abbrev-ef9cc920' -> '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/abbrev' 21371 error enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/abbrev-ef9cc920' -> '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/abbrev' 21371 error enoent This is most likely not a problem with npm itself 21371 error enoent and is related to npm not being able to find a file. 21372 verbose exit [ -2, true ] 

你遇到过类似的问题吗? 提前感谢您提出的任何build议。

卸载cordova,然后安装它为我工作。

 cd /usr/local/lib/node_modules/ sudo npm uninstall -g cordova sudo npm install -g cordova 

我和其他软件包有一样的问题。 我不得不从https://nodejs.org/en/download/重新安装节点。 对于我来说,当我试图在没有sudo的情况下全局安装软件包时,或者当我用ctrc + c取消一些安装软件包安装过程时,发生了这种情况 。 之后,没有办法解决它,但重新安装节点。 我也在Mac上,现在真的很关心让npm做它的工作…

用YARN解决

 sudo npm install -g yarn yarn install -g cordova 

我在Fedora Core 22上也发现了这个问题,安装最新的Apache Cordova(版本6.0.0)时,npm可能会错过使用sudo npm install -g cordova时的权限检查。

 npm ERR! enoent ENOENT, rename '/lib/node_modules/.staging/abbrev-cxxxxxx' 

npm ERR! enoent ENOENT, rename '/lib/node_modules/.staging/abbrev-xxxxxxx'

因此,以root身份运行( sudo -s )来解决这个问题,再运行npm install -g cordova ,问题就解决了。 (在我的环境中)。

对于我的环境(Fedora core 22),不需要从nodejs.org重新安装节点

先卸载cordova: npm uninstall -g cordova重新安装cordova npm install -g cordova