Cordova installation error: path issue (?) - error

2019-04-05 02:52发布

After installing Xcode & NodeJS I am now trying to install Cordova but I am getting the following error regarding a missing file (wrong 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 ]

Have you run into a similar issue? Thank you in advance for any suggestion you may have.

5条回答
混吃等死
2楼-- · 2019-04-05 03:07

I found this problem on Fedora Core 22 too when install latest Apache Cordova ( version 6.0.0 ) the problem may npm miss something about permission check when install with 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'

So solve this problem with run as root ( sudo -s ) and run npm install -g cordova again the problem will solve. ( In my environment ).

For my environment ( Fedora core 22 ) it does not need to reinstall node from nodejs.org

查看更多
你好瞎i
3楼-- · 2019-04-05 03:09

Solve it using YARN

sudo npm install -g yarn
yarn install -g cordova
查看更多
forever°为你锁心
4楼-- · 2019-04-05 03:16

Uninstalling cordova and then installing it worked for me.

cd /usr/local/lib/node_modules/
sudo npm uninstall -g cordova
sudo npm install -g cordova
查看更多
来,给爷笑一个
5楼-- · 2019-04-05 03:21

I had the same issue once with other packages. I had to reinstall node from here https://nodejs.org/en/download/. For me it happened when I tried to install packages globally without sudo, or when I was cancelling some installation package installation process with ctrc+c. After that there was no way to fix it but to reinstall node. I am also on a mac and now really carefull about letting npm do its job...

查看更多
看我几分像从前
6楼-- · 2019-04-05 03:24

First uninstall cordova : npm uninstall -g cordova The re-install cordova npm install -g cordova

查看更多
登录 后发表回答