npm package fails to install "npm ERR! Error: EACCES: permission denied"
pallatee opened this issue ยท 181 comments
While trying to install a packge with npm (for example lodash) it fails with error message:
npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "lodash"
npm ERR! node v5.10.1
npm ERR! npm v3.8.3
npm ERR! path /root/test/node_modules/.staging/lodash-9a2aabe2
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename
npm ERR! Error: EACCES: permission denied, rename '/root/test/node_modules/.staging/lodash-9a2aabe2' -> '/root/test/node_modules/lodash'
npm ERR! at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:25:7)
npm ERR! at FSReqWrap.oncomplete (fs.js:82:15)
npm ERR!
npm ERR! Error: EACCES: permission denied, rename '/root/test/node_modules/.staging/lodash-9a2aabe2' -> '/root/test/node_modules/lodash'
npm ERR! at Error (native)
npm ERR! [Error: EACCES: permission denied, rename '/root/test/node_modules/.staging/lodash-9a2aabe2' -> '/root/test/node_modules/lodash']
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! /root/test/npm-debug.log
I have tried to install it both with and without starting bash in administrator mode.
There is another wired thing about npm. When I try to install gulp globally I get:
Error: could not get uid/gid
net.js:135
this._handle.open(options.fd);
^
Error: EINVAL: invalid argument, uv_pipe_open
at Error (native)
at new Socket (net.js:135:18)
at createWritableStdioStream (internal/process/stdio.js:142:16)
at process.stdout (internal/process/stdio.js:10:14)
at console.js:99:37
at NativeModule.compile (node.js:395:5)
at Function.NativeModule.require (node.js:340:18)
at node.js:223:27
at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/uid-number/get-uid-gid.js:16:1)
at Module._compile (module.js:413:34)
at /usr/lib/node_modules/npm/node_modules/uid-number/uid-number.js:37:16
at ChildProcess.exithandler (child_process.js:209:5)
at emitTwo (events.js:100:13)
at ChildProcess.emit (events.js:185:7)
at maybeClose (internal/child_process.js:850:16)
at Socket.<anonymous> (internal/child_process.js:323:11)
at emitOne (events.js:90:13)
at Socket.emit (events.js:182:7)
at Pipe._onclose (net.js:475:12)
Same here. In fact if I try to update npm update -g npm@latest it attempts to copy lodash to the staging directory then throws the errror. Following this subsequent attempts to use npm are broken because it can no longer find lodash.
IMPORTANT
This really should be of utmost importance to the team. I for one was very excited and love how everything else works, but as you are adding this feature to windows with the intention of bringing web developers back to windows this needs fixing ASAP. This alone will stop me switching back to windows for web development and I'm sure it will be the same for many. It defeats the purpose of switching for me. Please please please fix.
@borovaka you can fix that error by allowing unsafe perms
npm config set unsafe-perm=true
Already tried. It bypasses the error but it still doesn't work. You will
get a permissions access error still or at least I did.
On Friday, April 8, 2016, John Christopher notifications@github.com wrote:
@borovaka https://github.com/borovaka you can fix that error by
allowing unsafe permsnpm config set unsafe-perm=true
โ
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#14 (comment)
@jamesscholeyweb right, I was able to get to your error after setting those perms. Otherwise I wasn't able to do anything.
This seems to be the underlying issue.
root@localhost:/usr/lib/node_modules/.staging# rename /usr/lib/node_modules/.staging/lodash-24c8c2f4 /usr/lib/node_modules/ember-cli/node_modules/babel-core/node_modules/lodash Bareword found where operator expected at (eval 1) line 1, near "24c8c2f4" (Missing operator before c8c2f4?) Unknown regexp modifier "/b" at (eval 1) line 1, at end of line syntax error at (eval 1) line 1, near "/."
Related: MicrosoftDocs/WSL#26
It seems to be an issue with symlinks
Confirmed - this is totally related to the symlink issue.
Same here with
npm install typescript
Here's the output
npm WARN enoent ENOENT: no such file or directory, open '/root/package.json'
npm WARN root No description
npm WARN root No repository field.
npm WARN root No README data
npm WARN root No license field.
npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "typescript" "gulp" "tsd"
npm ERR! node v5.10.1
npm ERR! npm v3.8.3
npm ERR! path /root/node_modules/.staging/ansi-regex-0de81b15
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename
npm ERR! Error: EACCES: permission denied, rename '/root/node_modules/.staging/ansi-regex-0de81b15' -> '/root/node_modules/ansi-regex'
npm ERR! at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:25:7)
npm ERR! at FSReqWrap.oncomplete (fs.js:82:15)
npm ERR!
npm ERR! Error: EACCES: permission denied, rename '/root/node_modules/.staging/ansi-regex-0de81b15' -> '/root/node_modules/ansi-regex'
npm ERR! at Error (native)
npm ERR! [Error: EACCES: permission denied, rename '/root/node_modules/.staging/ansi-regex-0de81b15' -> '/root/node_modules/ansi-regex']
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! /root/npm-debug.log
This looks a lot like #3. We can keep the conversation going on there.
What I can say right now is that things are getting better (at least in non-mnt directories.). On my dev box I see:
russ@RUSSALEX-DESK:~/tmp$ npm list
/home/russ/tmp
โโโ acorn@3.0.4
โโโฌ gulp@3.9.1
โ โโโ archy@1.0.0
โ โโโฌ chalk@1.1.3
โ โ โโโ ansi-styles@2.2.1
โ โ โโโ escape-string-regexp@1.0.5
โ โ โโโฌ has-ansi@2.0.0
โ โ โ โโโ ansi-regex@2.0.0
โ โ โโโฌ strip-ansi@3.0.1
โ โ โ โโโ ansi-regex@2.0.0
โ โ โโโ supports-color@2.0.0
โ โโโ deprecated@0.0.1
โ โโโฌ gulp-util@3.0.7
โ โ โโโ array-differ@1.0.0
It goes on from there. I should point out that I have not tried to actually use any of these, I have only installed them.
The team is hard at work getting stuff up and running. Npm is one of those things we're looking at now.
Full disclosure here. Doing a little more testing on our internal build and finding that doing an "npm -g install " still throws the uv_pipe_open error, even when in ~/tmp.
We have someone looking into it.
This seems also to be a valid issue when running npm in the new Windows 10 Bash
This solved it for me: https://gist.github.com/mattpodwysocki/4e6951fc93adae064a73ed0b2251d180
npm config set unsafe-perm true
I have no idea what it does however.
If you are using with -g option, try to remove it.
I just ran into this trying to do npm install -g ember-cli/ember-cli
on 15063.2. ๐
npm config set unsafe-perm=true
fixed it, but makes me uneasy.
You can bypass all permission problems by changing the prefix for npm.
See option 2: https://docs.npmjs.com/getting-started/fixing-npm-permissions
Actually I had already set the prefix
to a local user directory, and I was still getting this error.
To fully repro:
npm config set prefix="${HOME}/my-special-npm-directory"
npm install -g ember-cli/ember-cli
Hey, I just managed to fix an issue with my setup by taking ownership of the folder that Node was installed to. I use NVM to manage node versions, so in my case Node was installed in /home/myusername/.nvm
.
So, to fix it, I used sudo chown -R myusername:myusername /home/myusername/.nvm
. Weirdly enough, I had to run that command again each time I installed something globally, and I don't know enough to figure out why. It's a mystery!
The error still happens in Windows 10 Creator's Update 10.0.15063
. Here is what I tried:
- Turn off antivirus.
- After
npm install -g npm
check that npm was actually updated (>=4.4.4
). Runhash -r
to update bash cache.~/.profile
is not executed in current BashOnWindows, so move all npm-relatedPATH
modifications from~/.profile
to~/.bashrc
. - Even though I set prefix for npm to directory owned/
chown
ed by a user, I still runsudo npm install enduro -g
. - I get the error.
Does this happen if you don't use sudo
in step 3?
@aseering no, it didn't work unfortunately, same rename error on node v6.10.2
and npm 4.4.4
.
My anti-virus was blocking the download of packages.
Thanks ilyaigpetrov.
I used @Sparticuz suggested soluction and it's working fine.
restart your bash. It seems there's some permission timeout with forked(?) process.
Fixed this issue by putting sudo pm uninstall -g ember-cli
npm config set unsafe-perm=true work for me, thanks
sudo npm install -g npm@5.3.0
that sorted it for me
following @vinifala suggestion (reverting npm v5.4.0 to 5.3.0) fixed my recent permissions issues on Windows 10 git bash.
npm install -g npm@5.3.0
I just change my npm@5.4.1
to npm@5.3.0
, it's fine now.
You can use npm i -g npm@5.3.0
to downgrade.
@nagarajanewlife npm i npm@5.3.0
On windows 10 I was trying to update dependencies in my project with npm update --save
and it was returning permission errors. I tried to start the console in administrator mode but it wasn't solving the problem.
But with npm config set unsafe-perm=true
it worked
I fixed this issue using npm install -g npm@next
I am working on a Windows 7 pro
First, I tried doing sudo npm i -g npm
but it did not work. Then, I tried the option 1 here and got it to work.
Ergg... only thing that worked for me was to run my npm install in cmd.exe
- couldn't get it to work in WSL bash.
I'm running node 8.8.1
This is how I managed to get this to work:
- Start
CMD.exe
- Type
bash
sudo npm install -g npm@5.3.0
With the normal bash i could not get this to work.
@bitcrazed apologies for the delay. I wasn't doing global installs I was just doing a local install i.e. I was attempting to add @await/event
to my package.json using npm i "@await/event" --save-dev
. I kept getting EACCES
errors. I tried npm cache clean
- don't think I tried npm config set unsafe-perm true
- and then tried the same npm command within cmd.exe and it worked.
I'm unable to repeat the problem though - I just tried to create a new project today with npm init
and npm i "@await/event" --save-dev
- and it worked without problems in WSL bash.
sorry I can't give you more info to help pin it down, npm does seem to be behaving a bit more erratically in WSL of late but I'm usually able to get passed it with either (1) npm cache clean
or (2) running in cmd.exe - so I haven't bothered to dig too deeply.
Thanks for the note. Could well be that something else in your dependency graph was trying to do something that required root, but has since been fixed to permit local installation.
For example, in the OP's case, npm returned this:
npm ERR! path /root/test/node_modules/.staging/lodash-9a2aabe2
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename
npm ERR! Error: EACCES: permission denied, rename '/root/test/node_modules/.staging/lodash-9a2aabe2' -> '/root/test/node_modules/lodash'
npm ERR! at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:25:7)
npm ERR! at FSReqWrap.oncomplete (fs.js:82:15)
Here, the rename syscall was attempted by a process with insufficient rights, hence the EACCES
error.
Let us know if you see these issues in the future, though double-check whether you have to sudo
first, and/or compare the same action as a non-root user in a Linux VM.
@bitcrazed Ah interesting. I definitely had that problem in this case too (i.e. where the npm error message says 'EACCES ... blah ... try sudo' and then you try using sudo and it just gives you the same error message).
How do I tell whether I have the fix? I assume it's a fix in WSL bash?
I don't know if this applies, but I see many Mac users experiencing this issue due to macOS' different, sometimes more permissive security model vs. Linux.
This most often presents when a Mac user who authors or changes a node/npm package without realizing that their change will not work without sudo elevation on Linux.
I don't believe the fix was due to us - more likely that one of the packages was updated to eliminate this issue, though without a repro, it's hard to tell.
I had this issue and it turned out to be my AV. Disabled my AV and npm install worked.
I had this issue in WSL on windows. I had upgraded npm to 5.6.0 as it said there was an update available. Now I'm just using the Npm 5.5.1 that came with node 8.9.3.
So the problem seems to be updating Npm.
please help! how can i fix this? it gives the same error when i run the cmd as Administrator
npm ERR! path C:\Users\Kadon\AngularProjectX\node_modules\fsevents\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rmdir
npm ERR! Error: EPERM: operation not permitted, rmdir 'C:\Users\Kadon\AngularProjectX\node_modules\fsevents\node_modules'
npm ERR! { Error: EPERM: operation not permitted, rmdir 'C:\Users\Kadon\AngularProjectX\node_modules\fsevents\node_modules'
npm ERR! stack: 'Error: EPERM: operation not permitted, rmdir 'C:\Users\Kadon\AngularProjectX\node_modules\fsevents\node_modules'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rmdir',
npm ERR! path: 'C:\Users\Kadon\AngularProjectX\node_modules\fsevents\node_modules' }
I am facing the same issue, npm config set unsafe-perm=true
or node/npm upgrade didn't help.
Windows 10 (10.0.16299.309) @ WSL Ubuntu
node v9.9.0
npm 5.6.0
For instance I am trying to npm install
this repo: https://github.com/jenkins-docs/simple-node-js-react-npm-app
And getting this error:
username@Username-PC:/mnt/d/web/JavaScriptApps/jenkins-test$ npm install
npm ERR! path /mnt/d/web/JavaScriptApps/jenkins-test/node_modules/loader-fs-cache
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename
npm ERR! Error: EACCES: permission denied, rename '/mnt/d/web/JavaScriptApps/jenkins-test/node_modules/loader-fs-cache' -> '/mnt/d/web/JavaScriptApps/jenkins-test/node_modules/.loader-fs-cache.DELETE'
npm ERR! { Error: EACCES: permission denied, rename '/mnt/d/web/JavaScriptApps/jenkins-test/node_modules/loader-fs-cache' -> '/mnt/d/web/JavaScriptApps/jenkins-test/node_modules/.loader-fs-cache.DELETE'
npm ERR! cause:
npm ERR! { Error: EACCES: permission denied, rename '/mnt/d/web/JavaScriptApps/jenkins-test/node_modules/loader-fs-cache' -> '/mnt/d/web/JavaScriptApps/jenkins-test/node_modules/.loader-fs-cache.DELETE'
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/mnt/d/web/JavaScriptApps/jenkins-test/node_modules/loader-fs-cache',
npm ERR! dest: '/mnt/d/web/JavaScriptApps/jenkins-test/node_modules/.loader-fs-cache.DELETE' },
npm ERR! stack: 'Error: EACCES: permission denied, rename \'/mnt/d/web/JavaScriptApps/jenkins-test/node_modules/loader-fs-cache\' -> \'/mnt/d/web/JavaScriptApps/jenkins-test/node_modules/.loader-fs-cache.DELETE\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/mnt/d/web/JavaScriptApps/jenkins-test/node_modules/loader-fs-cache',
npm ERR! dest: '/mnt/d/web/JavaScriptApps/jenkins-test/node_modules/.loader-fs-cache.DELETE',
npm ERR! parent: 'my-app' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
Surprisingly Yarn is able to install dependencies.
For anyone facing this issue:
If you have mounted any windows folder in ubuntu so that you can use the command line functionalities and also GUI code editors through windows, this is bound to happen. Its because of some file locking rules done by windows.
So whenever this error comes up, close all the code editors or any other programs using this mounted folder in windows.
This has worked for me all the time.
It's hard to tell now what has fixed my issue, since I rebooted computer since then, but now it is gone. Will try IDE trick next time... thanks!
If you have mounted any windows folder in ubuntu so that you can use the command line functionalities and also GUI code editors through windows, this is bound to happen
This whole two year thread is #1529. The problem here is not permissions and never has been. [It is utterly unrelated to #3 which was a symlink problem, and how this one got closed.] You can install your whole NodeJS ecosystem as user yourself; you are still going to trip #1529. I asked in a related post that WSL at least throw off a (nonconforming) EBUSY
so we could differentiate from actual EACESS
problems but there was no response (what you gonna do).
Closing editors will help, if the thing holding open a handle is an editor. But if you take the example a couple of posts back, .loader-fs-cache
is still holding a handle. No one is editing anything there. Y'all have been rebooting and discovering "works fine now", because you've closed all the handles. And the thing is you've got open handles in node in spades much of the time, because of the client-server nature of the beast.
For now you can (a) be meticulous about making sure there are no file handles open in your node universe before running npm
(b) hope that your node packages get updated to be more tolerant of the problem and/or (c) wait for #1529 to flip.
@therealkenc can confirm it has to do with things being open elsewhere in your system, a pernicious and consistently annoying issue in Windows in general. At first I thought it was the ongoing node processes I had running from dev servers (I'd close them with task manager) but my latest test seems to indicate my text editor is the culprit, using Sublime Text 3. When I close it I can install modules normally.
Even adding node_modules
directory to the folder_exclude_pattern
and binary_file_patterns
settings I still have the issue somehow. Perhaps Sublime's project implementation is touching the directories still? Not sure. Atom doesn't seem to have the same issue (but I decided against using it on Windows since it apparently can't do multi-line find replace. I just can't win[dows]!).
I was able to solve this by going in the /usr/local/lib/node_modules/npm, and giving myself read and write permissions there. Then the same thing in /users/ME/.npm/_locks. Not sure why i didn't already have permissions in the last instance.
npm 2.5.1
@vickerym are you running NVM or no? I have all those permissions I believe but still had the issue.
@joeRob2468 thanks a bunch! Worked like a charm!
@vinifala thanks that worked for me!
I was not able to fix this problem with any of the above solutions (unsafe-perm, prefix, etc.). I do believe the issue is with open filehandles.
I installed yarn and it worked straight away.
If your workspace has package-lock.json
please remove and try again to npm i
. It might work, since i had a same issue in MS.
Fixed my install with NVM
and NPM 8.8.0
using:
sudo chown -R u:p node_modules
sudo chown -R u:p u/.nvm
Where u
is username and p
is password. Had to do this on both directories! Thanks for the tips above, chmod
wouldn't do.
Hope that helps someone!
PS - that was in the root directory of the project and root directory of WSL, respectively.
@jgchristopher Thank You ๐
npm config set unsafe-perm=true
worked for me :)
sudo chown -R myusername: /usr/local/lib/node_modules
This solved my issue
@jgchristopher Thank You ๐
npm config set unsafe-perm=true
worked for me :)
npm ERR! path E:\angulartemplate\coreui-free-angular-admin-template-master\coreui-free-angular-admin-template-master\node_modules.staging\end-of-stream-07f5179b\index.js
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'E:\angulartemplate\coreui-free-angular-admin-template-master\coreui-free-angular-admin-template-master\node_modules.staging\end-of-stream-07f5179b\index.js'
npm ERR! { Error: EPERM: operation not permitted, unlink 'E:\angulartemplate\coreui-free-angular-admin-template-master\coreui-free-angular-admin-template-master\node_modules.staging\end-of-stream-07f5179b\index.js'
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, unlink 'E:\angulartemplate\coreui-free-angular-admin-template-master\coreui-free-angular-admin-template-master\node_modules.staging\end-of-stream-07f5179b\index.js'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'E:\angulartemplate\coreui-free-angular-admin-template-master\coreui-free-angular-admin-template-master\node_modules\.staging\end-of-stream-07f5179b\index.js' },
npm ERR! stack: 'Error: EPERM: operation not permitted, unlink 'E:\angulartemplate\coreui-free-angular-admin-template-master\coreui-free-angular-admin-template-master\node_modules\.staging\end-of-stream-07f5179b\index.js'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'E:\angulartemplate\coreui-free-angular-admin-template-master\coreui-free-angular-admin-template-master\node_modules\.staging\end-of-stream-07f5179b\index.js',
npm ERR! parent: '@coreui/coreui-free-angular-admin-template' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
npm config set unsafe-perm=true
In my case it was VS Code locking a file in node_modules. Closing VS code unlocked the file and made the error go away. npm config set unsafe-perm true
, disabling antivirus etc. did not work.
If npm config set unsafe-perm=true
isn't working
Just try updating npm npm install -g npm
It is not recommended to use sudo
when installing npm packages.
Similarly, npm config set unsafe-perm true
should be avoided.
Regardless of security concerns, neither option is necessary. A better solution:
- Open a terminal from your home directory and make a new directory for global installs:
mkdir ~/.npm-global
- Configure npm to use the new directory path:
npm config set prefix ~/.npm-global
- Open or create a ~/.profile file (I use vim, use whatever) and add the following line:
export PATH=~/.npm-global/bin:$PATH
- After saving your ~/.profile ([Esc] -> :x! -> [Enter]), update system variables:
source ~/.profile
- Test your new configuration by installing a package globally without using
sudo
:
npm install -g pnpm
You can skip steps 2-4 if you prefer not to modify ~/profile by setting an ENV variable:
NPM_CONFIG_PREFIX=~/.npm-global
Things work better for me when I set fewer environment variables.. YMMV.
Tested with:
- Windows 10 Home - Insiders: Version 1903 Build 18353.1
- Visual Studio Code - Insiders: Version 1.33.0-user
- WSL: 4.4.0-18353-Microsoft
- Ubuntu: 18.04.2 LTS
- Node: 11.11.0
- npm: 6.7.0
Reference => official NPM docs:
FWIW our team was having this problem intermittently trying to npm install
on a mounted windows directory and were pulling our collective hair out re-installing node, checking versions, etc. It turns out it was just because we were all using vscode with the folder open in a workspace. You also need to make sure you don't have any running node processes (dev server, watching build script, etc). Once I shut all of those down I stopped getting the errors. I do suspect that there are many root causes of this issue though, and open file handles are just one of them.
Although, I'm using Ubuntu, I tried cleaning npm cache
sudo npm cache clear --force
and then it allowed me to run without sudo
npm i
The other options didn't work for me and I can't asure that this is the best option.
Fixed my install with
NVM
andNPM 8.8.0
using:sudo chown -R u:p node_modules sudo chown -R u:p u/.nvmWhere
u
is username andp
is password. Had to do this on both directories! Thanks for the tips above,chmod
wouldn't do.Hope that helps someone!
PS - that was in the root directory of the project and root directory of WSL, respectively.
'p' should be the group, not the password. If you put that as your password, anybody can see your password by viewing the file stats !!!!!
I've successfully worked around this issue, letting for example cordova function correctly.
My fix is at https://github.com/fuzzyTew/nodejswslfix . The library must be compiled by hand and preloaded into npm's environment, and it intercepts the problematic call, providing a quick fix to this issue.
npm would be able to resolve this issue by altering their concurrent behavior when moving multiple submodules out of the staging folder. I haven't mentioned it to them or looked at the npm code, myself.
^--- Added some discussion in #1529 since it has the virtue of still being open.
@borovaka you can fix that error by allowing unsafe perms
npm config set unsafe-perm=true
working ......thanks man
I tried every single solution posted in this issue but none of them worked,
but I did find a way to make things work again...
For me personally I was just trying to update npm module so I downloaded the latest nodejs binary from their website and unpacked it on windows, then I did
sudo rm -rf /usr/lib/node_modules/npm
in subsystem and copied only npm binary in the archive to the same place using Windows Explorer, and finally I
sudo chmod a+x /usr/bin/npm
Now npm is up to date without updating nodejs along with it!
For anyone who tried other solutions here but didn't work :)
EDIT: to open Windows Explorer in current directory is explorer.exe .
and you can navigate to root directory from there.
If it helps anyone I've traced it down to having vscode-insider open while npm installing.
When it's turned off, it appears to work fine. It might have something to do with the watchers.
This solved all my EACESS problem (on MAC):
sudo chown -R myusername: /Users/myusername/.npm/
@allain I can confirm this. Just shut down VSC Insider and my npm install worked fine.
If it helps anyone I've traced it down to having vscode-insider open while npm installing.
When it's turned off, it appears to work fine. It might have something to do with the watchers.
Yep. Confirmed here too
This fixed my issue
sudo chown -R $USER ~/.npm
Using MacOS Mojave
hey guys ,
if you using mac try running the command with sudo . it may help alot :)
This solved all my EACESS problem (on MAC):
sudo chown -R myusername: /Users/myusername/.npm/
Confirmed here too. Closed code-insiders and the error went away. Thanks so much.
If it helps anyone I've traced it down to having vscode-insider open while npm installing.
When it's turned off, it appears to work fine. It might have something to do with the watchers.
Same here as well. Win 10 WSL Ubuntu 18.04. Once I close code-insider it works like a charm.
This issue seems to come when changes are made to package.json file without npm knowing about it. Just do a plain npm install. Then install your module again. It should work.
This is one of the scenarios that worked for me. There might be other issues causing similar problems.
This issue seems to come when changes are made to package.json file without npm knowing about it. Just do a plain npm install. Then install your module again. It should work.
You're wrong there. This issue occurs when VSCode / VSCode Insiders is open in the project folder and you're trying an npm install
.
@hajimurtaza :
This issue seems to come when changes are made to package.json file without npm knowing about it. Just do a plain npm install. Then install your module again. It should work.You're wrong there. This issue occurs when VSCode / VSCode Insiders is open in the project folder and you're trying an
npm install
.
There is no one specific scenario that is triggering this issue. It happens for different reasons for different people: from VSCode & other apps being open, from npm installation ordering details, or from permissions settings. Some problems can be resolved by closing or changing something, but some are deeply rooted in the issue.
@hajimurtaza :
This issue seems to come when changes are made to package.json file without npm knowing about it. Just do a plain npm install. Then install your module again. It should work.You're wrong there. This issue occurs when VSCode / VSCode Insiders is open in the project folder and you're trying an
npm install
.There is no one specific scenario that is triggering this issue. It happens for different reasons for different people: from VSCode & other apps being open, from npm installation ordering details, or from permissions settings. Some problems can be resolved by closing or changing something, but some are deeply rooted in the issue.
Updated the answer.
I had node_modules installed before i installed nvm on the projet directory. Deleting them and running npm install
worked for me.
My issue was that npm
existed on both my Windows installation and my WSL instance. When I uninstalled NodeJS from WSL, and ran npm
, it would find and execute the Windows one. This leads me to believe that somewhere in the chain, the wrong npm
was being called which doesn't really have access to certain parts of the WSL file system.
I solved it my issue by removing NodeJS from Windows. Alternatively, I could have removed %APPDATA%\Roaming\npm
from the PATH
system environment. Or simply, disabling AppendNtPath
in the registry:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss]
"AppendNtPath"=dword:00000000
This is a known issue with VSCode remoting and WSL (Microsoft/WSL#3395, Microsoft/WSL#1956) and should be fixed in WSL2.
This is caused because VSCode remoting watches files, which prevents them from being accessed elsewhere. The fix is to tell VSCode to poll when remote instead of watch. See below:
ctrl+shift+p
then type & selectPreferences: Open Settings (JSON)
.- Add
"remote.WSL.fileWatcher.polling": true
to the config ctrl+shift+p
then type & selectDeveloper: Reload Window
.
For more information, see the documentation on VSCodes website regarding EACESS.
first run sudo su (as a root/administrator) and
run npm install -g typescript as a root/administrator y..
worked for me
If you are on windows, re-installing IIS on my solved the problem for me.
I've discovered it's an issue with open handles. VSCode can hold handles for longer than it should. Trying a command in just a bash shell open in Powershell can give EACESS errors. The act of just closing VSCode and trying the command again the bash shell works.
This has happened even when I close the related workspace on VSCode. The handle seems to only release when I actually close VSCode.
That doesn't make much sense, but perhaps the WSLv1 filesystem isn't properly closing files, or perhaps some logic faulty when a file handle is open and another tries to delete it?
It turns out it was just because we were all using vscode with the folder open in a workspace
This fixes it.
Got the same issue today running npm install -g gatsby-cli
on WSL 2.
npm config set unsafe-perm true
and npm config set unsafe-perm=true
couldn't solve the problem.
I also didn't had my VSC open.
sudo chown -R $(whoami) ~/.npm
and sudo chown -R $(whoami) /usr/lib/node_modules
got me further but didn't solve the problem since gatsby wants to write into /usr/bin/gatsby
.
Had to sudo it.
After following this this and this tutorials, I was able to install it without sudo.
Turns out it was just a matter of using nvm.
Got the same issue today running
npm install -g gatsby-cli
on WSL 2.
npm config set unsafe-perm true
andnpm config set unsafe-perm=true
couldn't solve the problem.I also didn't had my VSC open.
sudo chown -R $(whoami) ~/.npm
andsudo chown -R $(whoami) /usr/lib/node_modules
got me further but didn't solve the problem since gatsby wants to write into/usr/bin/gatsby
.Had to sudo it.
After following this this and this tutorials, I was able to install it without sudo.
Turns out it was just a matter of using nvm.
Yes, you're installing it globally so you need to use sudo
. NVM can indeed go around it since the packages are installed in your home folder instead.
Using sudo
worked.
sudo npm install -g npm@latest
# Remove nvm
rm -rf $HOME/.nvm
# Install latest nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
Latest install script can be found
https://github.com/nvm-sh/nvm#install--update-script
I just ran WSL as admin and everything seems to be okay.....for now :) So now I am able to rum rm -rf npm install etc.
cheeers
It turns out it was just because we were all using vscode with the folder open in a workspace
This fixes it.
Yes. For me too.
To be clearer:
I closed VSCode. Instead of using VSCode integrated terminal, I used the Ubuntu 18.04 LTS app directly (in Windows, this opens a terminal).
@allain I can confirm this. Just shut down VSC Insider and my npm install worked fine.
great! thanks!!
Figured you don't even have to close VSC, just make sure the directory is not currently open in the files list.
Thanks for the tip!!!
npx [package]
example to Ionic: npx ionic