Vue-cli: NPM install fails for @vue/cli with Error: EPERM: operation not permitted, rename

Created on 8 Sep 2018  路  21Comments  路  Source: vuejs/vue-cli

Version

3.0.1

Reproduction link

http://nolink

Node and OS info

Node v8.11.4 / Windows 7

Steps to reproduce

npm install -g @vue/cli

What is expected?

Successful install

What is actually happening?

Error: EPERM: operation not permitted, rename


tried running as admin but still same error

end lines from log
8917 verbose unlock done using C:\Users\pkumarAppData\Roaming\npm-cache_locks\staging-64e07ed02ac4e2e4.lock for C:\Users\pkumarAppData\Roaming\npm\node_modules.staging
8918 verbose stack Error: EPERM: operation not permitted, rename 'C:\Users\pkumarAppData\Roaming\npm\node_modules\rimrafpackage.json.189012702' -> 'C:\Users\pkumarAppData\Roaming\npm\node_modules\rimrafpackage.json'
8919 verbose cwd C:\Users\pkumar\workspace\NodeJs\VUE\vue-cli3
8920 verbose Windows_NT 6.1.7601
8921 verbose argv "C:\Program Files (x86)\nodejs\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "@vue/cli"
8922 verbose node v8.11.4
8923 verbose npm v5.6.0
8924 error path C:\Users\pkumarAppData\Roaming\npm\node_modules\rimrafpackage.json.189012702
8925 error code EPERM
8926 error errno -4048
8927 error syscall rename
8928 error Error: EPERM: operation not permitted, rename 'C:\Users\pkumarAppData\Roaming\npm\node_modules\rimrafpackage.json.189012702' -> 'C:\Users\pkumarAppData\Roaming\npm\node_modules\rimrafpackage.json'
8928 error { Error: EPERM: operation not permitted, rename 'C:\Users\pkumarAppData\Roaming\npm\node_modules\rimrafpackage.json.189012702' -> 'C:\Users\pkumarAppData\Roaming\npm\node_modules\rimrafpackage.json'
8928 error cause:
8928 error { Error: EPERM: operation not permitted, rename 'C:\Users\pkumarAppData\Roaming\npm\node_modules\rimrafpackage.json.189012702' -> 'C:\Users\pkumarAppData\Roaming\npm\node_modules\rimrafpackage.json'
8928 error errno: -4048,
8928 error code: 'EPERM',
8928 error syscall: 'rename',
8928 error path: 'C:\Users\pkumar\AppData\Roaming\npm\node_modules\rimraf\package.json.189012702',
8928 error dest: 'C:\Users\pkumar\AppData\Roaming\npm\node_modules\rimraf\package.json' },
8928 error stack: 'Error: EPERM: operation not permitted, rename \'C:\Users\pkumar\AppData\Roaming\npm\node_modules\rimraf\package.json.189012702\' -> \'C:\Users\pkumar\AppData\Roaming\npm\node_modules\rimraf\package.json\'',
8928 error errno: -4048,
8928 error code: 'EPERM',
8928 error syscall: 'rename',
8928 error path: 'C:\Users\pkumar\AppData\Roaming\npm\node_modules\rimraf\package.json.189012702',
8928 error dest: 'C:\Users\pkumar\AppData\Roaming\npm\node_modules\rimraf\package.json' }
8929 error Please try running this command again as root/Administrator.
8930 verbose exit [ -4048, true ]

Most helpful comment

Update on this
After looking at the log error msg
I ran
npm install -g decompress-tar

and then reran npm install -g @vue/cli and it worked so above pkg was not getting installed via cli process

All 21 comments

Update on this
After looking at the log error msg
I ran
npm install -g decompress-tar

and then reran npm install -g @vue/cli and it worked so above pkg was not getting installed via cli process

Seems like an npm issue:
https://github.com/react-community/create-react-native-app/issues/191
https://github.com/Medium/phantomjs/issues/19
https://github.com/npm/npm/issues/10826
https://blogs.msdn.microsoft.com/matt-harrington/2012/02/23/how-to-fix-node-js-npm-permission-problems/

Some possible solutions worth a try:

  • Disable all anti-virus softwares
  • npm cache clean --force
  • Close any Node.js process and retry with a new prompt window

npm cache clean -force

Can't disable the antivirus; cleaning npm cache and running as admin doesn't help.

I tough I was going crazy, can't install either. I clear the cache, run as admin, remove @vue from roaming and nothing helps...

@AleksueiR after a lot of trial/error this works:

execute npm config edit
look for the entry
cache-lock-retries=10

set the value to 1000 (or any bigger number)
cache-lock-retries=1000

@skayablars Thanks! I'll try that. This totally makes sense though - McAfee is likely locking files trying to scan them.

I was getting nowhere with this yesterday and ended up installing vue-cli on a VM, and then copying the
@vue folder from Roaming/npm over to my machine. That worked, butt's very clumsy.

@skayablars Thanks! I'll try that. This totally makes sense though - McAfee is likely locking files trying to scan them.

I was getting nowhere with this yesterday and ended up installing vue-cli on a VM, and then copying the
@vue folder from Roaming/npm over to my machine. That worked, butt's very clumsy.

Something that I forgot to say is that I contact support in my company to disable McAfee while I resolved the issue

Try run: npm uninstall vue-cli -g
After run again npm install -g @vue/cli

That's works for me

sudo chown -R myusername: /usr/local/lib/node_modules

This worked for me!

Solution: yarn global add @vue/cli

nothing is working from me.
cache cleaned
disabled antivirus

can you please help me

I have the same error when I try to build my vue-cli app. Installing the dependencies and serving the app works fine. But ...

Error: EPERM: operation not permitted, lstat '[PATH_TO_PROJECT]\dist'

appears on Windows 10. Didnt try with Apple and Linux yet.

What I have tried:

  • npm cache clean --force
  • edit npm config
  • uninstall and install vue-cli
  • run npm run build with system32 rights

EDIT: My solution is linked in @sodatea 's answer: https://github.com/npm/npm/issues/10826#issuecomment-206534390 I closed the Atom Editor

I tried all of them like you but at last this thing for me
Delete node module folder in user\my.usernameAppData\Roaming\npm

Let me know if it works for you

I had the same issue but using PS as admin as opposed to CMD as admin seems to have worked. No idea how or why.

Try this command :

npm install -g @vue/cli --cache /tmp/empty-cache

to use a temporary cache instead of nuking the actual one.
It worked for me.

Same issue here. Win10. A system restart solves my problem.....

Seems like an npm issue:
expo/create-react-native-app#191
Medium/phantomjs#19
npm/npm#10826
https://blogs.msdn.microsoft.com/matt-harrington/2012/02/23/how-to-fix-node-js-npm-permission-problems/

Some possible solutions worth a try:

  • Disable all anti-virus softwares
  • npm cache clean --force
  • Close any Node.js process and retry with a new prompt window

thanks npm cache clean --force works for me

same issue. nothing is working.
what's the hell ?

I had the same issue. The following command worked for me:
npm install -g @vue/cli --unsafe-perm

Was this page helpful?
0 / 5 - 0 ratings

Related issues

OmgImAlexis picture OmgImAlexis  路  3Comments

chasegiunta picture chasegiunta  路  3Comments

joshuajohnson814 picture joshuajohnson814  路  3Comments

Gonzalo2683 picture Gonzalo2683  路  3Comments

Akryum picture Akryum  路  3Comments