uname -a: Linux localhost 3.18.14-11422779 #1 SMP PREEMPT Thu Jun 1 19:35:14 KST 2017 aarch64 Android0.48 on Android 7.0.I have created an issue here https://github.com/npm/npm/issues/17480 and @whao created an issue here https://github.com/npm/npm/issues/17480 - both are the same thing, and it's getting no traction from the npm community, so I'm trying here since it's only happening in Termux.
I think there's something weird happening there, since it's trying to symlink between two folders in the home folder... but it's still complaining about permission issues. I spent some serious time trying to figure out the problem, but the npm code is not easy to follow. You'll find more information in the ticket itself: https://github.com/npm/npm/issues/17480
Here's the original ticket content. Any ideas for me to explore are welcome, since npm is pretty central to my workflow.
important the issue does not happen with the version bundled with nodejs, which is 3.10.10 today. It's only happening with the 5.x versions.
Running this (or any global/local package for that matters) using npm 5.0.3 or 5.0.4:
npm i -g npm
fails like this:
> npm i -g npm --verbose
npm info it worked if it ends with ok
npm verb cli [ '/usr/bin/node',
npm verb cli '/data/data/com.termux/files/usr/bin/npm',
npm verb cli 'i',
npm verb cli '-g',
npm verb cli 'npm',
npm verb cli '--verbose' ]
npm info using [email protected]
npm info using [email protected]
npm verb npm-session 3b7ba2a77f7e848c
Unhandled rejection Error: EACCES: permission denied, link '/home/.npm/_cacache/tmp/6a547224' -> '/home/.npm/_cacache/content-v2/sha512/d8/e0/f8cb9554c1f6f974b32fe943e4df8353fca3cb4843dbeda6fe0d88d14eb91bec5d23ddde1751af76721044d662b479ec4c9df9f0bfcce592bbc9fc2b6f72'
at Error (native)
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! A complete log of this run can be found in:
npm ERR! /home/.npm/_logs/2017-06-28T00_20_47_543Z-debug.log
The only two things included in the log that are not in the message:
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
I then tried uninstalling node, deleting everything and re-installing everything and I could install the latest npm version successfully (from 3.10.10 to 5.0.4), but after that I have the same problem installing grunt-cli or bower.
I have the same issue with local packages (e.g. npm i in a project with a valid package.json or npm i gulp), and the same two additional lines in the log file.
Note that there's no such thing as sudo, everything runs under the same user in Termux. Also, since Termux does not have root access to Android, everything runs under /data/data/com.termux/files/, e.g. ~ is /data/data/com.termux/files/home, and node lives under /data/data/com.termux/files/usr/bin/node. This was not an issue before, but here are some useful links if that helps:
#! before each script uses the termux-fix-shebang at install to make scripts work out of the box: https://github.com/termux/termux-packages/blob/master/packages/termux-tools/termux-fix-shebang (e.g. cat $(which npm) prints #!/data/data/com.termux/files/usr/bin/env node) - here's the patch: https://github.com/termux/termux-packages/blob/master/packages/nodejs/deps-npm-lib-build.js.patchThis being said, the issue is happening at runtime, and the printed paths in the error message are correct.
Let me know if I can provide additional details.
apt install nodejsnpm i -g npm@latestmkdir test && cd test), optionally doing an npm init though that's not requirednpm i gulp (you can try a global or a local install)npm -v prints: 5.0.3 and 5.0.4node -v prints: 6.11.0npm config get registry prints:when i first install nodejs and npm, npm running well.
but, after i upgrade my npm with this command npm i -g npm
i got error like you.
to solve this problem, i installed yarn as my javascript package manager.
@Jehanramadhan that's actually a good idea :)
Finally found the problem and a workaround:
proot --link2symlink npm i -g npm
The problem is that termux does not support hardlinks. So any system that only allows symlink will fail.
I won't have time to propose an upstream fix soon, so in the meantime there's at least a workaround. I guess we could also patch npm...
My workaround works only partially. Using this with npm i still happily throws ENOENT for every package
I am having this same problem on ChromeOS using nodejs-current termux package (npm 5.3.0). That proot workaround works for most packages I've tried so far. Still having issues installing certain things (eg. bcrypt) but the errors are different and probably unrelated to this issue.
Creating configuration file ionic.config.json - done!
[INFO] Installing dependencies may take several minutes!
npm install
✖ Running command - failed!
[ERROR] An error occurred while running npm install (exit code 1):
Unhandled rejection Error: EACCES: permission denied, open
'/home/jays/.npm/_cacache/tmp/e3e6f00e'
Unhandled rejection Error: EACCES: permission denied, open
'/home/jays/.npm/_cacache/tmp/76d075ca'
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! A complete log of this run can be found in:
npm ERR! /home/jays/.npm/_logs/2017-08-31T08_34_56_417Z-debug.log
npm running command failed during creating new project
I installed nodejs-current and tried npx signalhub and I get EACCES in the link operation too. Wrapping that with proot as suggested makes lstat fail with EPERM.
Same issue with nodejs-current
node -v prints 8.4.0.
npm -v prints 5.3.0.
I think more information can be found here: https://github.com/golang/dep/issues/947
These issues seem to have the same core issue: hardlinks not being supported (enough) on AUFS and in Termux.
Something similar was found in OpenSSH on Termux, here's how it was fixed: https://github.com/termux/termux-packages/commit/6bbba8f22a14ec12e942950417414be0e67620ea
Hope that helps.
Can someone explain to me why npm i worked just fine for me with nodejs, but with nodejs-current it doesn't? Does nodejs-current come with a different version of npm? And does this different version do something with symlinks which the old npm did not do? Couldn't we just install an old version of npm then? I mean the version of npm shouldn't really matter, right? I mean they all point to the same repository, so you'd essentially get the same stuff, right?
@T-vK nodejs 6.0 indeed comes with an older version of npm, and it's starting with version 5 that this "issue" began happening. In other words, the issue is just with npm version 5 and up, and it comes by default with nodejs 8+ (current). You can use yarn, but you'll have to manually fix shebangs...
I don't really know what yarn is. I'd much rather just use an old version of npm. Any idea how I could install npm version <5, but keep nodejs-current?
Yarn is just another package manager: https://yarnpkg.com/en/ (it won't "just work" anyway, you'll have to fight a little bit with it!) - You can see my post here: https://github.com/termux/termux-packages/issues/853 for an idea.
As for installing an older version of npm, I guess you could do something like npm install -g [email protected] but since npm doesn't work... :P In the meantime, I don't really have a good solution for you. This is where things are expected to happen, but since npm relies on hardlinks, and using proot doesn't "just work" either", I'm also stuck: https://github.com/npm/npm/issues/17480
I was having a similar issue because I had already installed the regular nodejs package before installing nodejs-current. Uninstalling both and then reinstalling nodejs-current fixed.
My workaround for now: Instead of npm i, do this:
packages install nodejs -y && npm i && packages install nodejs-current -y
It will obviously take quite a bit longer than a normal npm i, but hey, at least you don't get any errors and don't have deal with a different package manager.
idk why people dont use apt. it's quicker to type
keep watching this problem ! Hope fixed quick
Got same issue when installing http-server using package nodejs-current
[01:48] ~ > npm install http-server --global
Unhandled rejection Error: EACCES: permission denied, link '/data/data/com.termux/files/home/.npm/_cacache/tmp/a62d0816' -> '/data/data/com.termux/files/home/.npm/_cacache/content-v2/sha512/6e/80/8040ea20747c25f0e31a6782d61a4f2017e677d3f1ed3bad1c8379c4f37ea8b90f7c0fae377780a9e759da90a864bfef9e95ede289c9691b43bca4006384'
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! A complete log of this run can be found in:
npm ERR! /data/data/com.termux/files/home/.npm/_logs/2017-10-27T20_18_08_311Z-debug.log
I think the problem should be solved upstream https://github.com/npm/npm/issues/17480 unless someone figures out a way to fully emulate hardlinks. For godep https://github.com/golang/dep/issues/947 there is a similar issue for which the solution is to change godep code...
So, workarounds and patches should go here but the fix will only happen upstream.
It seems like the only reason npm's cache uses hardlinks is to simplify, or make more atomic, the operation of moving a file (rename()ing it). A patch fixing this issue is present in #1701. I have also sent a PR upstream to zkat/cacache#110.
The patch by @karolba is included in updated versions of nodejs (at version 8.9.0-1) and nodejs-current (at version 9.0.0-1), so after updating with pkg up npm should work again!
The issue returned on nodejs-current v9.2.0
@lsvidal What package are you trying to install? I see no regression with neither lodash, express, nor server-js.
Did you by any chance happen to update npm by issuing npm install -g npm? That could break it as it would remove the patches provided by Termux.
got problem even though already try the solution above.
EACCESS: permission denied,.......
I am trying to build apps using Ionic.
Thanks
On Sat, Sep 1, 2018, 12:10 AM Dimitrios Proios notifications@github.com
wrote:
Worked with this:
sudo chown -R $USER:$GROUP ~/.npm
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/termux/termux-packages/issues/1192#issuecomment-417713103,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AjgWu9KjH6HoaZn2DwvGCGNmXwMRJ-xoks5uWWAHgaJpZM4OrkEL
.
Give ownership to npm like this:
sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config
I solved this issue by not using npm anymore and use yarn instead
npm i -g npm
That seems to be an easy fix.
How I resolved it: remove nodejs and npm (in my case "sudo apt remove nodejs npm" worked).
Install nodejs again. (in my case "sudo apt-get install nodejs").
npm is included in the package with nodejs.
if you are having trouble in installing nodejs again, you can refer to
https://linuxize.com/post/how-to-install-node-js-on-ubuntu-18.04/
PS: Still facing issue?
if you are the only user that is accessing this project then,
you can delete the node_modules directory and install it again with npm install and that will give the node_modules the desired user permissions.
else
you have to give the required permissions to node_modules directory by
sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config
Done!
Thankyou
Given permission to that folder as webhacking suggested,,, thanks man
@Jean-Barbosa9 and others, I think everyone is confused here :) This is the termux packages repository, and there is no sudo nor permissions here. You probably intended to post something on the npm repository instead.
Maybe you can try this
sudo chown -R username /home/.npm/
running
npm cache clean
worked for me!
When i upgrade nodejs in v10.16.3 and npm v6.9.0 in my ubuntu 18.04 OS. I am having this same problem. Then i give permission by running this command and solve this problem,
sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config
Done !!
Thank You
I think a lot of people get the repos mixed up. This is specific to Termux, Ubuntu is another story.
Most helpful comment
Give ownership to npm like this: