简体   繁体   中英

when using NVM, unable to install npm packages globally

I am using NVM in windows, which basically switches between the versions of nodeJs by changing the shortcut it creates in "C:\\program files\\nodejs"

when I do

nvm use 7.0

then the shortcut is updated to "c:\\users\\me\\AppData\\Roaming\\nvm\\v7.0"

if I use 4.6, then "c:\\users\\me\\AppData\\Roaming\\nvm\\v4.6"

As the actual node files sits inside NVM folder...

All the files inside "C:\\program files\\nodejs" are locked, becoz of this, when I run

npm install -g package

, as part of installation process it tries to rename some files/directories, which it couldnt, and it fails....

-info using npm@3.10.8
-info using node@v7.0.0
-error Error: EPERM: operation not permitted, rename 'C:\Program Files\nodejs\node_modules\@angular\cli' -> 'C:\Program Files\nodejs\node_modules\@angular\.cli.DELETE'
-error  Error
-error     at moveAway (C:\Users\me\AppData\Roaming\nvm\v7.0.0\node_modules\npm\lib\install\action\finalize.js:38:5)
-error     at destStatted (C:\Users\me\AppData\Roaming\nvm\v7.0.0\node_modules\npm\lib\install\action\finalize.js:27:7)
-error     at FSReqWrap.oncomplete (fs.js:111:15)
-error
-error Error: EPERM: operation not permitted, rename 'C:\Program Files\nodejs\node_modules\@angular\cli' -> 'C:\Program Files\nodejs\node_modules\@angular\.cli.DELETE'
-error Please try running this command again as root/Administrator.
-verbose exit [ -4048, true ]

I have been able to install packages globally before NVM, now I couldnt. I tried unlocking "program files\\nodejs\\node_modules" no errors, but the dir remains locked.

unlocking may not be the right approach as whenever we switch to other node version, it will get locked again.

I dont have admin rights, but that shouldnt be a problem i suppose...

I think the issue is exactly with admin rights.

As a workaround, you can install package inside your project, and access it's binary in ./node_modules/.bin/ folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM