Cordova安装错误:路径问题(?) - 错误代码ENOENT

时间:2016-02-04 00:32:26

标签: node.js macos cordova npm ionic-framework

安装Xcode& NodeJS我现在正在尝试安装Cordova,但是我收到了关于丢失文件的错误(错误的路径?)。

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 ]

你遇到过类似的问题吗?如果您有任何建议,请提前感谢您。

5 个答案:

答案 0 :(得分:48)

卸载cordova,然后安装它对我有用。

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

答案 1 :(得分:4)

使用YARN解决它

sudo npm install -g yarn
yarn install -g cordova

答案 2 :(得分:3)

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

答案 3 :(得分:1)

我在安装最新的Apache Cordova(版本6.0.0)时也在Fedora Core 22上发现了这个问题,问题可能会在安装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重新安装节点

答案 4 :(得分:1)

首先卸载cordova: import java.util.*; public class LeapYear { public static void main(String[] args) { Scanner input=new Scanner(System.in); boolean four ; boolean hundred; boolean four_hundred; boolean quit=true; int check= 2000; int min=1582; String test; //System.out.println("Enter a year to check if it is a leap year"); do { do { System.out.println("Enter a year to check if it is a leap year"); if(check <min ) { System.out.println("That year is too old, choose a year in more recent history"); } check =input.nextInt(); } while( check < min); // check =input.nextInt(); if(check % 4==0) { four=true; } else { four=false; } if(check%100==0) { hundred=true; } else { hundred=false; } if(check %400==0) { four_hundred=true; } else { four_hundred=false; } if(four==true) { if(four==true&&hundred==false&&four_hundred==false) { System.out.println("The year is a leap year"); } if(four==true&&hundred==true&&four_hundred==false) { System.out.println("The year is not a leap year"); } if(four==true&&hundred==true&&four_hundred==true) { System.out.println("The year is a leap year"); } } else { System.out.println("The year is not a leap year"); } System.out.println("DO YOU WANT TO QUIT: Y/N ?"); while(!input.hasNext("true|false")) { System.out.println("That is neither a true or false."); input.nextBoolean(); if(input.hasNextBoolean()) { quit=true; } if(input.hasNextBoolean()) { quit=false; } } } while(!quit==false); } } 重新安装cordova npm uninstall -g cordova