Closed pallatee closed 8 years ago
well, I still have the issue. sudo chown -R $(whoami) /usr/lib/node_modules
and sudo chown -R $(whoami) ~/.npm
didn't worked. sudo npm i -g npm
throws this error:
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/.staging/npm-3e479054/node_modules/yargs
npm ERR! dest /usr/local/lib/node_modules/.staging/yargs-1b99ab7e
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/.staging/npm-3e479054/node_modules/yargs' -> '/usr/local/lib/node_modules/.staging/yargs-1b99ab7e'
npm ERR! [OperationalError: EACCES: permission denied, rename '/usr/local/lib/node_modules/.staging/npm-3e479054/node_modules/yargs' -> '/usr/local/lib/node_modules/.staging/yargs-1b99ab7e'] { npm ERR! cause: [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/.staging/npm-3e479054/node_modules/yargs' -> '/usr/local/lib/node_modules/.staging/yargs-1b99ab7e'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/lib/node_modules/.staging/npm-3e479054/node_modules/yargs',
npm ERR! dest: '/usr/local/lib/node_modules/.staging/yargs-1b99ab7e'
npm ERR! },
npm ERR! stack: "Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/.staging/npm-3e479054/node_modules/yargs' -> '/usr/local/lib/node_modules/.staging/yargs-1b99ab7e'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/lib/node_modules/.staging/npm-3e479054/node_modules/yargs',
npm ERR! dest: '/usr/local/lib/node_modules/.staging/yargs-1b99ab7e'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
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.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/kamil/.npm/_logs/2019-11-15T12_54_32_666Z-debug.log
VSCode is closed, like every other node process via killall node
.
NPM was installed via NVM and copied to /usr/local
via:
n=$(which node); \
n=${n%/bin/node}; \
chmod -R 755 $n/bin/*; \
sudo cp -r $n/{bin,lib,share} /usr/local
Installing any given node version via NVM works. Trying to update any NPM for the selected version gives the same error as above.
Tried aliasing the npm prefix - didn't work as well.
I'm still using https://github.com/microsoft/WSL/issues/14#issuecomment-481028594 to work around this reliably. Don't use VSCode myself.
I'm still using #14 (comment) to work around this reliably. Don't use VSCode myself.
I could not make this to work, I don't know if I doing it right. Please, tell me where I'm wrong:
I executed the following:
sudo apt-get install libcapstone3
sudo ln -s $(pwd)/*.so* /usr/lib
And then when I do that:
LD_PRELOAD=/usr/lib/interceptrename.so npm install
I have the error:
ERROR: ld.so: object '/usr/lib/interceptrename.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/interceptrename.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
npm WARN saveError ENOENT: no such file or directory, open '/usr/lib/package.json'
npm WARN saveError EACCES: permission denied, open '/usr/lib/package-lock.json.4069992860'
npm WARN enoent ENOENT: no such file or directory, open '/usr/lib/package.json'
npm WARN lib No description
npm WARN lib No repository field.
npm WARN lib No README data
npm WARN lib No license field.
I'm using ubuntu on WSL2.
@samuelpares you need to put the libraries in /usr/lib for that usage to work. See https://github.com/fuzzyTew/wslunpindir#quick-installation . EDIT: sorry, after rereading your post, I see you did that. It should work, but you could try rebuilding the code yourself. I'm afraid Idon't have my Windows system around anymore to test, maybe somebody else can comment?
It looks like you might have made an error, switching folders to /usr/lib for your npm command. Similarly, when you run the sudo ln
command, you must be in the wslunpindir folder.
Try to use sudo -S npm i
npm adduser --registry=http://xx.xx.xx.xx then: npm publish --registry=http://xx.xx.xx.xx
@Kogam22 I have been struggling for hours and hours with this and i never thought to close vscode. ARGHHHHH you're a good man.
This issue was closed as a duplicate of #3 by @russalex, but it's not related to symlinks and should still be open.
Edit: the current issue is #1529.
I'm still having the problem even though I closed VSCode and used:
sudo npm install -g npm@latest
@tripol do you have any luck with https://github.com/microsoft/WSL/issues/14#issuecomment-481028594 ?
Strange it used to be all I had to do was close vscode to get rid of this error, now it is coming up all the time. I am trying to install npm because it recommended me to for a patch and I get this error now. I have tried sudo I have tried adding the "remote.WSL.fileWatcher.polling": true
to vscode even though it is closed anyways. I am stuck here
Still have the same issue, this is ridiculous! Opened in 2016 still not resolved.
If you're using nvm
see if there's a .nvmrc in the project you're in. Just doing an nvm use
to make sure you're on the correct version of node solves this problem for me. If you had a failed attempt, remove node_modules before attempting to install again after switching node versions.
Get this error in 2020 (after openninig this issue in 2016) it still appearing. What the heck?! With this problem, I cannot to delete ./node_modules/ in my react project on last version of Windows LTSC. And VS Code does not support IntelliSense and autocomplete with error of access.
Ghost methods with unsafe-perm=true
and sudo
not worked. At least sudo not supported in Git Bash on Windows.
And with old projects I have no this issue (created about half year ago). That feeling that problem in release of Create React App. But I can't understand where is the problem to fix it by self.
So I have to work on a machine with WSL v1 (no issues on v2). I can replicate it pretty easily by trying to install a package with VSCode. I believe there's some sort of access limit or open handles.
Basically, I know VSCode is monitoring the folder I'm working in. If I install a package with VSCode is open, I'll get EACCESS errors. If I close VSCode and install the packages over the Ubuntu bash, no errors.
So, to create this issue, I believe you just have to:
npm install
)I would think VSCode isn't handling the file system changes faster than npm
can create or delete them. That's why this only happens sometimes and on some machines. The machine I'm working on currently is REALLY slow in general and I get this errors consistently if I try it installing a package with VSCode open. WSLv2 may have fixed this issue, or it's just so much faster than WSLv1 that the it's rare for the collision to occur.
I tried npm cache clean --force
and then perform npm install
and it works for me
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.
I've tried many other solutions and none of them has worked! This one did!!! Thanks
Anyone who got here with this issue whilst trying to run npm i
in VSCode remote WSL:
Restart VSCode or close VSCode and run npm in your terminal. Seems to be a separate issue where VSCode is holding onto file references or something.
the Microsoft team should look into this ASAP, things like this might keep people from coming back to windows. Just saying.
Like @G1itcher said, close VSCode and run npm install
and it will work, I just follow those steps and my project worked. One more thing, npm should not be run using sudo , a couple of people recommended that.
Same here with WSL1. Incredibly annoying that every time you want to install a npm module you should close VScode so the remote server allows you to install. React apps get broken also.
As a new developer, this issue has had me stumped for days. In order to keep in-line with the rest of the team who use Linux or MacOS, I have to develop through WSL. This issue really needs to be solved.
For me, closing VSCode, opening WSL terminal and running npm install there worked.
Experiencing the same issue. Hopefully some kind of fix is on the works
For me, closing VSCode, opening WSL terminal and running npm install there worked.
Same worked for me. I am using WSL 1. Do we have any permanent solution?
Having fun with this issue currently. My solution was like the others, close the windows based program and then it might work. I found that I had to manually close the handle to the root folder as some things were still holding it open (explorer.exe even with no windows in the open). Another solution is to run the build command line within the Linux home directory instead of a shared storage. Then copy it over.
Thumbs up, same problem, same solution: close vscode... I was really hoping that WSL would be a way to go this year :/
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
I had the same problem, but you have to write "sudo npm i -g typescript" and it worked. :)
I was trying to install broccoli and broccoli-plugin-rollup locally, got the error and was able to solve it using npm cache clean --force
and rerunning the npm i -D broccoli broccoli-rollup
command inside the wsl terminal of VS Code so this isnt necessarily an issue of VS Code either (but I'm not saying that this is never the reason. It might solve the problem in other situations as well).
Not sure what else to try but consistently running into this issue on Ubuntu 18.04 WSL 2 on 19033.
Node v12.13.0, NPM v. 6.12.0. 1. Running npm i -g npm
with npm installed via nvm to get away from global restrictions. $NVM_DIR
, set in ~/.bash_profile
pointing to /home/myuser/.nvm
and I've tried sudo chown -R $(whoami) $HOME/.nvm
, cleaning the cache, and setting npm config set unsafe-perm=true
but so far no luck. Previously I think I had installed node via curl (?) and it showed in usr/lib/
but removed those directories and now which npm
and which node
shows the correct nvm locations. Still no luck, even with VS Code closed and on repeat attempts. Error messages seem to always revolve around node/versionnumber/lib/node_modules/.staging
.
In my case I was having 2 npm versions installed. One version was installed on WSL , another one on Windows. After removing Windows version I`ve got no errors yet..
Finally got a fix: ensured I did a full uninstall of any global (non-nvm) node/npm directories with sudo apt-get purge --auto-remove nodejs
(and whether this next bit was necessary or not) reinstalled my node version by doing nvm install [other_version]
, nvm uninstall [current_version]
, then reinstalled. Now working fine at the moment. Assuming there was something still trying to point to files in that original node install.
I also had this issue. This worked for me:
sudo npm install --global
For me, the following 2 solutions worked -
What @shalomsam suggested worked for me. Thanks!
I just removed the package-lock.json and node_modules, then npm install and all worked!
Nothing suggested above worked for me on:
I removed my original comment since I just realized I wasn't on WSL2 🤦
@shayc if you have some basic dev skills you can almost certainly make the workaround I made with my other account at https://github.com/fuzzyTew/wslunpindir work for you, so long as the issue is not an open windows process: that solution only handles directory trees that aren't used outside wsl. @pallatee is there any chance you could edit your first post to summarize the current situation? A lot of people are repeatedly offering the same solutions. Microsoft is fixing this in their next release. A lot of people are also running into the issue because they have VSCode open, and closing it fixes it for them.
Sorry, I did not read that you were using WSL2 and were informing us that it isn't actually fixed in that release. I don't know if my workaround works in WSL2: I don't actually use windows myself anymore.
I updated Windows to version 2004 today so I could use WSL2. I am now encountering this exact issue for the first time, having never been troubled by it in WSL1.
Windows 10 2004
WSL 2 WSL 1
Ubuntu 20.04 LTS
nvm v0.35.3
node v12.18.0
npm v6.14.4
Edit: Apparently my distro was somehow still on WSL 1, even though it was installed after running wsl --set-default-version 2
. Apologies for the false alarm.
Hey quick fix! Instead of using npm install -g typescript use sudo npm install -g typescript Hope that helps. :)
I've come up with another possible solution
npm set unsafe-perm true
here is a link
I had the same problem, it has been fixed using nvm and wsl 2.
Before that I tried:
I followed all the steps and all worked fine for me. https://docs.microsoft.com/en-us/windows/nodejs/setup-on-wsl2
Note: I'm using Windows 10 Home Single Language
I had the same problem, it has been fixed using nvm and wsl 2.
Before that I tried:
- set unsafe-perm true
- sudo npm install --global
- Uninstaslling node from windows
- Running Ubuntu as administrator
- Uninstalling and installing with sudo
I followed all the steps and all worked fine for me. https://docs.microsoft.com/en-us/windows/nodejs/setup-on-wsl2
Note: I'm using Windows 10 Home Single Language
+1 it fixed the same issue for me after moving from dirictly installed nodejs to nodejs intalled from nvm. Thank you very much! You saved my hours!
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.I've tried many other solutions and none of them has worked! This one did!!! Thanks
thanks man this save me c:
I have finally solved the issue. In my case it was related to mounted folder. You have to move your project into WSL file system. For instance to /home Additionally you will get super speed from it!
Relaunching the VSCode worked for me. I was installing sharp using npm install sharp
.
sudo npm install -g npm
worked for me
Hey quick fix! Instead of using npm install -g typescript use sudo npm install -g typescript Hope that helps. :)
It works
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
I had the same problem, but you have to write "sudo npm i -g typescript" and it worked. :)
我也遇到过同样的问题,但是你必须写“ sudo npm i-g typescript” ,结果奏效了。 :)
不行 如果用了sudo npm xxxx就会报npm找不到命令
npm config set unsafe-perm true
It works
And you are'nt the only one (check previous posts) problem is using sudo / disable permission is considered a bad practice. That's my solution for the moment but I feel weird, exposed, I feel like a hacker is waiting under my bed while I'm sleeping :| I don't like that feeling
I completely agree. Unfortunately nothing else solves the problem. I will stay tuned.
While trying to install a packge with npm (for example lodash) it fails with error message:
I have tried to install it both with and without starting bash in administrator mode.