npm / npm

This repository is moving to: https://github.com/npm/cli
http://npm.community
17.53k stars 3.03k forks source link

npm install fails on Windows: "Error: EPERM: operation not permitted, rename" #10826

Closed barbalex closed 8 years ago

barbalex commented 8 years ago

I work on Windows 10, up to date installation. npm i runs in powershell node v5.2.0 npm v3.3.12

This error occures every time. I have repeated 5 times, deleting the node_modules folder beforehand. I have also run it twice as administrator. It works on my OsX notebook.

Here the error message in powershell:

npm WARN EPACKAGEJSON ae@1.0.0 No repository field.
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i"
npm ERR! node v5.2.0
npm ERR! npm  v3.3.12
npm ERR! path C:\Users\alex\ae\node_modules\.staging\escope-b5ac5ca528edb372dbff854e4a2941fb
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename

npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\alex\ae\node_modules\.staging\escope-b5ac5ca528edb372db
ff854e4a2941fb' -> 'C:\Users\alex\ae\node_modules\escope'
npm ERR!     at Error (native)
npm ERR!  { [Error: EPERM: operation not permitted, rename 'C:\Users\alex\ae\node_modules\.staging\escope-b5ac5ca528edb3
72dbff854e4a2941fb' -> 'C:\Users\alex\ae\node_modules\escope']
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\Users\\alex\\ae\\node_modules\\.staging\\escope-b5ac5ca528edb372dbff854e4a2941fb',
npm ERR!   dest: 'C:\\Users\\alex\\ae\\node_modules\\escope',
npm ERR!   parent: 'ae' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\alex\ae\npm-debug.log

This is the complete log from npm-debug.log: https://gist.github.com/barbalex/da6100299bf5b76f19c2

This is the project: https://github.com/barbalex/ae This is package.json: https://github.com/barbalex/ae/blob/master/package.json

jlzg commented 7 years ago

npm cache clean worked for me as well.

toddhalfpenny commented 7 years ago

Hey all, I was trying this over and over with different admin rights, npm cache clean etc etc with no joy. I then did the following, and had success... though not sure yet which piece(s) of the puzzle helped.

toddhalfpenny commented 7 years ago

Update on above - it seems, for me at least, that the issue was having the project folder open in sublime text. Nuts!

ericgrosse commented 7 years ago

Had the same issue, had to close Sublime entirely and npm cache clean before it finally worked. Strange too because I always have Sublime open and never had a problem until now.

morristhai commented 7 years ago

Ran into the same problem with installing lodash.

Finally worked with these steps:

  1. Disabled antivirus (Windows Defender)
  2. Ran npm cache clean
  3. Deleted node_modules directory
  4. Made sure text editor (Atom) was closed
  5. Ran npm install lodash --save
chiranjeevisaride commented 7 years ago

Same Issue please help node -v v7.5.0 npm -v 4.1.2 NOTE: tried doing "npm cache clean" didn't work

npm ERR! Windows_NT 10.0.14393 npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" npm ERR! node v7.5.0 npm ERR! npm v4.1.2 npm ERR! path C:\Users\Chiranjeevi\Desktop\angularJS\ang2\angular2-seed\node_modules.staging\base64id-47d544ab\package.json.1971791659 npm ERR! code ENOENT npm ERR! errno -4058 npm ERR! syscall rename npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\Chiranjeevi\Desktop\angularJS\ang2\angular2-seed\node_modules.staging\base64id-47d544ab\package.json.1971791659' -> 'C:\Users\Chiranjeevi\Desktop\angularJS\ang2\angular2-seed\node_modules.staging\base64id-47d544ab\package.json' npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\Chiranjeevi\Desktop\angularJS\ang2\angular2-seed\node_modules.staging\base64id-47d544ab\package.json.1971791659' -> 'C:\Users\Chiranjeevi\Desktop\angularJS\ang2\angular2-seed\node_modules.staging\base64id-47d544ab\package.json' 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! C:\Users\Chiranjeevi\Desktop\angularJS\ang2\angular2-seed\npm-debug.log

yaronlevi commented 7 years ago

Have been having the issue on win7 RN 0.41.

After 2 days I found it !!

you need to manually delete the "build" folder inside: my_react_native_app\android\app

See that it works, and come back here and give this a post a party icon, to save hours of frustration for other RN devs (-:

dfoverdx commented 7 years ago

Updating to node 6 fixed this for me. I also deleted everything node-related in %appdata%\roaming, but I had done that before updating to node 6, and it didn't help, so it's hard to say if that deletion was important.

alrahmanak commented 7 years ago

I had the same problem and I tried many of the suggestions mentioned above none worked. Finally switched my account to a user account instead of an administrator account in Win 10 Home. This solved my problem

Christian24 commented 7 years ago

I fixed this by moving the entire project folder to a different partition. It seems Windows hates it when it is on C: drive.

johntemyra commented 7 years ago

I struggled with this error message when I tried to install packages with npm. During this struggle I tried the following with no success:

  1. running command as administrator
  2. npm cache clear
  3. moving the npm folder and npm-cache folder location to c:/ in order to reduce the paths length
  4. Setting folder permissions
  5. Removing the node_modules folder
  6. Sometimes after a reboot of the computer I was able to install one or two packages but the error persisted.

What finally solved my problem was when I installed npm-junction! (as suggested here https://github.com/npm/npm/issues/3861) + running as administrator

davloperez commented 7 years ago

Hi everyone. I had the same issue, both 4058 with "rename" and 4048 with "unlink" phases of npm install. npm cache clean and stop Windows Defender didn't help. I finally have resolved this by un-sharing a parent folder of the project. After remove folder sharing with everyone, all npm-install works fine.

mrshlthmps commented 7 years ago

I struggled as many did above installing angular cli on Windows 7 behind a corporate proxy. Turns out, it seems to be the Windows cmd windows itself somehow causing the issue. I used Cygwin and it worked the first time.

Opened Cygwin as root - not sure if the root was necessary.

npm config set https_proxy=https://myusername:mypassword@webproxy.mycompany.com:8080 npm cache clear npm install -g @angular/cli

CMCCHEMC commented 7 years ago

I Delete the npm folder in C:\Users\Administrator\AppData\Roaming\npm ,Retry npm install And It works! so fxxking windows

avinash221988 commented 7 years ago

npm cache clear worked for me. Thanks!!

harishrsk commented 7 years ago

for me the issues was,i opened the cmd prompt normally which was not having permission to create a new directory,so i ran the cmd prompt as administrator which was able to create new directory.problem solved

bradlymathews commented 7 years ago

For me, rebooting the computer removed the file locks and I was able to install the package.

mechcow commented 6 years ago

I had this problem and it was because I had the folder open in Android Studio. Trying to rename the folder in Windows Explorer and that helped to understand what was going on because you got a clearer error message "Another program has the file open". Hope that helps someone.

shezankazi commented 6 years ago

I had this problem as well. What worked for me:

  1. shut down all node instances in task manager
  2. Delete folder AppData/node
  3. run npm clean cache
  4. run npm install
murthyravi commented 6 years ago

Unhide AppData folder if it is hidden.

kathleenvv commented 6 years ago

Following steps worked for me:

jquintozamora commented 6 years ago

Solution for me was:

  1. Close VS Studio Code
    del package-lock.json
    rd /s /q node_modules
    npm cache clear --force
    npm i 
Philyorkshire commented 6 years ago

This is an issue with Visual Studio Code. It must be holding onto a process which is blocking the npm install script.

MuhammadTaha commented 6 years ago

try disabling your anti virus

janpio commented 6 years ago

If you are using Visual Studio Code and have this problem, here is an issue about that you can track: https://github.com/Microsoft/vscode/issues/28593

rahmanAi commented 6 years ago

i installed for windows 7,64bit npm cache clean solve the issue for me,TQ guys

mchandu123 commented 6 years ago

I also got the same issue, then i just disabled the avast antivirus, then it worked for me. thank you guys .

KhagayN commented 6 years ago

npm cache clean -f

BradKwon commented 6 years ago

"npm cache verify" solved the issue on mine instead of "npm cache clean -f". I have npm 5.3.0 and it seems like npm recommends "verify" instead of "clean" to fix cache corruption problems.

JNaeemGitonga commented 6 years ago

I rolled my version of npm back to 4.2.0. things worked then and now I am back up and running.

npm install -g npm@4.2.0

jedu0309 commented 6 years ago

I try to rm -rf .node-sass.DELETE. it works

ghost commented 6 years ago

Problem seemed intermittent until one day just always presented itself. I have a network mounted drive for the files in question and Avast AV as well. None of the solutions above worked (npm cache clean -f worked sometimes until nothing worked). Then I found this. Solution: https://alastaircrabtree.com/fixing-intermittant-eperm-operation-not-permitted-on-npm-install/

mayurbaldha commented 6 years ago

Just run cmd as administrator and keep updated node v6.11 and npm v5.3

Then after that you can use all features of global node packagers without running cmd as administrator.

NiklasBeierl commented 6 years ago

I am fairly new to npm and I have been fondling with this problem since yesterday. One thing that I noticed ist that it always failed at a "post-install script" I don't know if this belongs to the modules or to npm itself. Affected pacakges I recall: electron, angular, jquery

Spend about 8 to 10 hours total to figure this out, which included: Reinstalling node and npm multiple times Re-applying all windows file permissions. Downgrading node / npm. Disabling Windows Defender. Clearing the npm-cache ("even though I apparently am not supposed to do that."

However, what I found working in the end: use --force I am so done.

Mardoxx commented 6 years ago

Similar issue on vsts - windows hosted agent with npm@5.4, installing npm@5.3 works.

superkarn commented 6 years ago

None of the above worked for me (clearing cache, disabling antivirus, reinstalling node/npm, etc.). What eventually worked for me was deleting these folders.

C:\Users\[username]\AppData\Roaming\npm
C:\Users\[username]\AppData\Roaming\npm-cache
alhugot commented 6 years ago

with npm@5.4: npm ERR! code EPERM npm ERR! errno -4048 npm ERR! syscall unlink rolling back to npm@5.3 works

neilrackett commented 6 years ago

I had the same issue with unlink on Windows, resolved using npm i -g npm@5.3, so it looks like an issue with NPM 5.4.

EchoDeveloper commented 6 years ago

Solution. npm uninstall npm -g npm install npm@5.3 -g Congratulations!

yaskevich commented 6 years ago

npm cache verify did help.

Valsym commented 6 years ago

EchoDeveloper, thanks! Real work for me: npm uninstall npm -g npm install npm@5.3 -g

chatodesouza commented 6 years ago

I deleted these folders:

C:\Users\[username]\AppData\Roaming\npm
C:\Users\[username]\AppData\Roaming\npm-cache

Then; npm --force uninstall npm -g npm install npm@5.3 -g

And, IT WORKED!!

RianaL commented 6 years ago

Disabling the antivirus worked for me too. I just had to talk to one of our sys admins to do that for me as I do not have permission.

prageethmadhu commented 6 years ago

After huge struggle found the solution for me .. 👍

"Create new folders" mkdir E:\Buildagent\npm
mkdir E:\Buildagent\npm-cache

"move npm prefix and the cache" robocopy c:\Users\the-build-user\AppData\Roaming\npm E:\Buildagent\npm
robocopy c:\Users\the-build-user\AppData\Roaming\npm-cache E:\Buildagent\npm-cache /E /MOVE

"Update the npm config for prefix and cache" npm config set prefix E:\Buildagent\npm
npm config set cache E:\Buildagent\npm-cache

https://alastaircrabtree.com/fixing-intermittant-eperm-operation-not-permitted-on-npm-install/

jesshyl commented 6 years ago

this is fxxking annoying me, none of above solutions works for me, im thinking of leaving reactjs now

ps. npm install -g npm@5.3 works for me now, finally...

Mardoxx commented 6 years ago

@jesshyl don't let the (dis)functionality of npm put you off reactjs. In fact, the two have little to do with each other, npm merely supplies you with packages! If you don't want to live with the brokenness of npm, you can use yarn instead, which works as a drop-in replacement.

LordHabicht commented 6 years ago

logging in as root/Administrator on Windows fixed the issue for me. That is, the "Administrator" Account. Another account with Administrator privileges was not sufficient

jesshyl commented 6 years ago

@Mardoxx thx mate , problem fixed now , i modified the edition of npm from 5.4 to 5.3, and finally successed...

anshumanfinicity commented 6 years ago

I m too facing same issue with Node version - 8.4.0 npm version - 5.4.0 (tried 5.3/ 5.2/5.1) OS - windows

Eror log -

npm WARN Error: EPERM: operation not permitted, scandir 'F:\Users\apatil\workspace\mv5\node_modules\fsevents\node_modules\dashdash\node_modules' npm WARN { Error: EPERM: operation not permitted, scandir 'F:\Users\apatil\workspace\mv5\node_modules\fsevents\node_modules\dashdash\node_modules' npm WARN stack: 'Error: EPERM: operation not permitted, scandir \'F:\Users\apatil\workspace\mv5\node_modules\fsevents\node_modules\dashdash\node_modules\'', npm WARN errno: -4048, npm WARN code: 'EPERM', npm WARN syscall: 'scandir', npm WARN path: 'F:\Users\apatil\workspace\mv5\node_modules\fsevents\node_modules\dashdash\node_modules' } npm verb npm verb Please try running this command again as root/Administrator. npm verb stack Error: ENOENT: no such file or directory, chmod 'F:\Users\apatil\workspace\mv5\node_modules\sequelize-cli\lib\sequelize' npm verb stack at runAction (C:\Users\apatil\AppData\Roaming\npm\node_modules\npm\lib\install\actions.js:74:13) npm verb stack at actions.(anonymous function) (C:\Users\apatil\AppData\Roaming\npm\node_modules\npm\lib\install\actions.js:50:17) npm verb stack at execAction (C:\Users\apatil\AppData\Roaming\npm\node_modules\npm\lib\install\actions.js:197:18) npm verb stack at runCallback (timers.js:781:20) npm verb stack at tryOnImmediate (timers.js:743:5) npm verb stack at processImmediate [as _immediateCallback] (timers.js:714:5) npm verb stack From previous event: npm verb stack at withInit (C:\Users\apatil\AppData\Roaming\npm\node_modules\npm\lib\install\actions.js:165:15) npm verb stack From previous event: npm verb stack at withInit (C:\Users\apatil\AppData\Roaming\npm\node_modules\npm\lib\install\actions.js:181:13) npm verb stack at runSerial (C:\Users\apatil\AppData\Roaming\npm\node_modules\npm\lib\install\actions.js:164:10) npm verb stack at doSerial (C:\Users\apatil\AppData\Roaming\npm\node_modules\npm\lib\install\actions.js:145:3) npm verb stack at Array. (C:\Users\apatil\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\bind-actor.js:15:8) npm verb stack at LOOP (C:\Users\apatil\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\chain.js:15:14) npm verb stack at C:\Users\apatil\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\chain.js:18:7 npm verb stack at withInit.nodeify (C:\Users\apatil\AppData\Roaming\npm\node_modules\npm\lib\install\actions.js:137:5) npm verb stack at runCallback (timers.js:781:20) npm verb stack at tryOnImmediate (timers.js:743:5) npm verb cwd F:\Users\apatil\workspace\mv5 npm verb Windows_NT 10.0.14393 npm verb argv "C:\Program Files\nodejs\node.exe" "C:\Users\apatil\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "i" "--verbose" npm verb node v8.4.0 npm verb npm v5.3.0 npm ERR! path F:\Users\apatil\workspace\mv5\node_modules\sequelize-cli\lib\sequelize npm ERR! code ENOENT npm ERR! errno -4058 npm ERR! syscall chmod npm ERR! enoent ENOENT: no such file or directory, chmod 'F:\Users\apatil\workspace\mv5\node_modules\sequelize-cli\lib\sequelize' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent npm verb exit [ -4058, true ]

futureMegao commented 6 years ago

@neilrackett It's work for me,Thx