Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on the new version of NPM #13293

Closed
guritso opened this issue Nov 19, 2022 · 39 comments
Closed

Error on the new version of NPM #13293

guritso opened this issue Nov 19, 2022 · 39 comments
Assignees
Labels
bug report Something is not working properly nodejs Issue is about Node.js related stuff, including npm

Comments

@guritso
Copy link

guritso commented Nov 19, 2022

I'm getting this error on the version 9.1.2 of npm:

npm ERR! code EACCES
npm ERR! syscall link
npm ERR! path /data/data/com.termux/files/home/.npm/_cacache/tmp/4f642a1f
npm ERR! dest /data/data/com.termux/files/home/.npm/_cacache/content-v2/sha512/be/ab/0cbc90e0f25082fb10a4b6cbae24791280fb9c61657faeea92f50ace86a920874b1dc0377c202e3e1b25d5067bbb2f526e14d1d0e5c7aa146dbbcb0ed718
npm ERR! errno EACCES
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR!   sudo chown -R 10413:10413 "/data/data/com.termux/files/home/.npm"

npm ERR! A complete log of this run can be found in:
npm ERR!     /data/data/com.termux/files/home/.npm/_logs/2022-11-19T20_47_59_413Z-debug-0.log

As I don't have root , I can't solve it with what is indicated in the log

This happens with anything I try, like

npm install package
npm install -g npm
@Grimler91
Copy link
Member

It tries to make a hardlink, which is not allowed on android. Same issue as in #11293, where npm install -g package worked as a work around

@truboxl
Copy link
Contributor

truboxl commented Nov 20, 2022

I think we should patch this, if this version of npm is what we provide

@truboxl truboxl added the bug report Something is not working properly label Nov 20, 2022
@licy183
Copy link
Member

licy183 commented Nov 20, 2022

Maybe we should report this issue to https://github.com/npm/cacache? We have patched it using https://github.com/termux/termux-packages/blob/master/packages/nodejs/deps-npm-node_modules-cacache-lib-util-move-file.js.patch, but if user tries to update npm or cacache, the patch will not work.

@xtkoba xtkoba added the nodejs Issue is about Node.js related stuff, including npm label Nov 20, 2022
@thunder-coding
Copy link
Member

@GuriZenit, we are talking about native Termux environment and not proot based distributions (including third party ones).

@xtkoba
Copy link
Contributor

xtkoba commented Dec 15, 2022

We really need a gimmick that forbids users' updating npm, if the patch is not likely to be merged upstream. Could be just a matter of documentation though.

@thunder-coding
Copy link
Member

Yeah sure @xtkoba, we can add a notice to the npm's global install script when installing npm. Just wait for some time though. My main device is for repair so I can't test the binaries built by CI. Once it comes, will look into it

@thunder-coding thunder-coding self-assigned this Dec 16, 2022
@licy183
Copy link
Member

licy183 commented Jan 6, 2023

It seems that [email protected] has fixed this.

@guritso
Copy link
Author

guritso commented Jan 6, 2023

It seems that [email protected] has fixed this.

Still have the error, both now and when testing in v9.2.0 release. does it work for you?

@licy183
Copy link
Member

licy183 commented Jan 6, 2023

Emmm... It seems to work on Bluestacks, but not on my real device. I will record it and report upstream.

@ginger-tek
Copy link

It seems that [email protected] has fixed this.

Still have the error, both now and when testing in v9.2.0 release. does it work for you?

Same here :/

@OurCodeBase
Copy link

Use yarn to install npm packages !

@thunder-coding
Copy link
Member

Just pushed 6b05a8e. Will now include an error message when trying to install npm globally. Also using --force will allow to install it anyway (provided for people who know what they are doing)

@elenakrittik
Copy link

So, uh, any other way to upgrade npm?

@Alex1Sturm
Copy link

Error;-;

ERR! Can't install npm globally as it will very likely break installation of global packages using npm. See #13293

npm ERR! A complete log of this run can be found in:
npm ERR! /data/data/com.termux/files/home/.npm/_logs/2023-03-12T00_03_10_133Z-debug-0.log

@marktforsyth
Copy link

So, uh, any other way to upgrade npm?

@ItsAleph I think I may have found a way!

Ironically, the suggestion by @OurCodeBase works perfectly for this: using yarn. Even though I've been getting the same errors as everyone else, this did the trick:

npm i -g yarn (if not already installed)
yarn global add npm

Oh my machine, this runs without errors. After installation, npm -v gives the expected result. Does this work for any of you too?

@joshcangit
Copy link

joshcangit commented Apr 21, 2023

No, yarn global add npm only installed under the home directory.

But leaving the system-wide npm module alone is the only option.
Overwriting it in any way will cause this issue.

If I need a more up-to-date npm, best is to get it with yarn or pnpm.

@OurCodeBase
Copy link

Hello @joshcangit
If you are facing issues with yarn then reset everything and install yarn using package manager pkg install yarn.
This will install yarn, npm, and nodejs automatically.
And then you can run yarn command anywhere.

@joshcangit
Copy link

Hello @joshcangit
If you are facing issues with yarn then reset everything and install yarn using package manager pkg install yarn.
This will install yarn, npm, and nodejs automatically.
And then you can run yarn command anywhere.

Um actually, the issue is with npm.

I updated it by installing under the home directory then copying it over.
I don't think it matters which package manager I used to do this.

@OurCodeBase

This comment was marked as off-topic.

@joshcangit
Copy link

Why are you using npm when yarn is much stable than it.

My idea is npm for system-wide packages.
But yarn or pnpm for packages in current working directory.

@elenakrittik

This comment was marked as off-topic.

@Leif-W
Copy link

Leif-W commented May 26, 2023

Using yarn to install npm globally, initially seems to work, but upon closer examination, using a tool like npm-check-updates, reveals that it doesn't completely work as expected. ncu -g will show the old (no longer installed 9.6.3) version as installed, and the currently installed (9.6.7) as available for install. 'yarn' != 'npm', therefore, yarn is not updating the same (config?) files as npm, thus, issues remain. It's a quick and dirty workaround, which may be sufficient for some scenarios and/or people, and not sufficient for others. Nothing beats a proper fix.

@phanirithvij
Copy link

phanirithvij commented May 27, 2023

This has been fixed in npm/cacache#195, it works now

@thunder-coding
Copy link
Member

This has been fixed in npm/cacache#195, it works now

Thanks for pointing out, this issue will be closed as completed once we have upgrade to a version of nodejs which comes with this fix for npm. LTS should not be much of a problem, but the latest version will take some time to catch up

@varxez
Copy link

varxez commented Jul 4, 2023

@joshcangit
Copy link

https://github.com/varxez/termux-npm-updater

Not sure if this works.
I've tried copying npm from node_modules in the home folder.
The error still occured.

@thunder-coding
Copy link
Member

You can try this:
https://github.com/varxez/termux-npm-updater

That script ain't going to work, you are just replacing the npm binary and the node_modules directory without actually applying the fix which we have in our packaged version of node

@varxez
Copy link

varxez commented Jul 4, 2023

You can try this:
https://github.com/varxez/termux-npm-updater

That script ain't going to work, you are just replacing the npm binary and the node_modules directory without actually applying the fix which we have in our packaged version of node

Bro, how about if you personally check the functionality of the script?

@guritso
Copy link
Author

guritso commented Jul 4, 2023

You can try this:
https://github.com/varxez/termux-npm-updater

That script ain't going to work, you are just replacing the npm binary and the node_modules directory without actually applying the fix which we have in our packaged version of node

Bro, how about if you personally check the functionality of the script?

This script does the same job as

npm i -g npm@latest --force

@elenakrittik

This comment was marked as off-topic.

@TomJo2000

This comment was marked as off-topic.

@Leif-W
Copy link

Leif-W commented Jul 8, 2023

This seems to have gone off topic. The name has nothing to do with the functionality. Nor does bickering about a script.

For me, the patched npm was available in a nodejs update in my Termux some time ago. At some later time, npm was independently updated upstream somewhere, so that the version installed was out of date. npm i -g npm worked flawlessly, and npm updated without any errors. I verified new version with npm -v.

If some people are still having a bug, then let them please continue to explore that here. To troubleshoot, I think it might be reasonable to uninstall nodejs then verify the old npm is truly gone, then reinstall nodejs and verify it has the patched npm. Then wait for a new npm to be released upstream, and try to self-update.

Only people still kbserving the initial problem should be posting here. Otherwise, if others confirm this is now working and nobody reports errors, close this. Probably any other bug is a new bug and deserves a new issue.

Thanks to all who got this working for us.

@n-ce
Copy link

n-ce commented Jul 22, 2023

Screenshot_20230723-003114_Termux
same Issue on latest LTS.

@Leif-W
Copy link

Leif-W commented Jul 22, 2023

npm -g i npm worked for me. So people will need more details to reproduce. Like which version of nodejs is installed? I've got node v20.2.0. Did you uninstall and reinstall nodejs? What is the LTS version? nodejs-lts is v18.16.1? Did the patch get backported upstream? Will it ever? Did you try nodejs (current)? Is upgrading nodejs possible? IDK what else to try, that's all I did and things worked since the upstream patch landed.

@Leif-W
Copy link

Leif-W commented Jul 23, 2023

nodejs-lts has nodejs v18.16.1 and npm v9.5.1. The fix landed in cacache v17.0.7. npm v9.5.1 is using cacahe v17.0.4. cacache v17.0.7 doesn't land in npm until npm v9.6.6, which doesn't land in node until node v18.17.0, which is the very next release after node v18.16.1. Can nodejs-lts simply be bumped up to v18.17.0 to fix npm self-updates?

@Leif-W
Copy link

Leif-W commented Jul 25, 2023

Now when I uninstall nodejs-lts and reinstall nodejs which has the upstream-fixed npm v9.6.6, I can't upgrade because the outdated Termux patch which references this issue 13293 is still applied. (Edit: I may have previously upgraded using yarn but then forgot. See workaround below.)

So 2 things:

  1. For nodejs package, remove the unneeded packages/nodejs/deps-npm-lib-commands-install.js.patch as nodejs npm v9.6.6 includes cacache v17.0.7 which was fixed for this issue upstream in cacache v17.0.4.

  2. For nodejs-lts package, can we bump up one release, from 18.16.1 to 18.17.0 to include npm v9.6.6? If yes, then likewise delete the cruft deps-npm-lib-commands-install.js patch.

As a workaround, use yarn or possibly another package manager (pnpm gave me a problem which I've not yet diagnosed), to install npm globally. yarn global add npm Then use npm to install itself globally to the same version (npm -g i npm), to clobber any cruft left behind by yarn which may cause discrepancies in reported (i.e. npm v9.6.6) vs installed version (i.e. npm v9.8.1). (I use npm-check-updates which shows the discrepancy.)

@guritso
Copy link
Author

guritso commented Jul 25, 2023

Now when I uninstall nodejs-lts and reinstall nodejs which has the upstream-fixed npm v9.6.6, I can't upgrade because the outdated Termux patch which references this issue 13293 is still applied. (Edit: I may have previously upgraded using yarn but then forgot. See workaround below.)

So 2 things:

  1. For nodejs package, remove the unneeded packages/nodejs/deps-npm-lib-commands-install.js.patch as nodejs npm v9.6.6 includes cacache v17.0.7 which was fixed for this issue upstream in cacache v17.0.4.

  2. For nodejs-lts package, can we bump up one release, from 18.16.1 to 18.17.0 to include npm v9.6.6? If yes, then likewise delete the cruft deps-npm-lib-commands-install.js patch.

As a workaround, use yarn or possibly another package manager (pnpm gave me a problem which I've not yet diagnosed), to install npm globally. yarn global add npm Then use npm to install itself globally to the same version (npm -g i npm), to clobber any cruft left behind by yarn which may cause discrepancies in reported (i.e. npm v9.6.6) vs installed version (i.e. npm v9.8.1). (I use npm-check-updates which shows the discrepancy.)

It happened to me, I was wondering why it worked at first, but not on reinstallation, but I used npm i -g npm --force instead.

bigbio2002 pushed a commit to bigbio2002/termux-packages that referenced this issue Feb 27, 2024
This should hopefully silence people complaining of unable to update but
npm is showing an update being available.

Closes termux#13293
@Leif-W
Copy link

Leif-W commented Aug 29, 2024

Again, I have been bypassing this ridiculous limitation for over a year with no ill effects. The upstream bug which initially triggered this problem has long since been fixed, as noted above, though stubborn illiteracy prevails here. The ostrich fix here, to not check for updates and pretend they don't exist, and keep applying a patch for a problem that no longer exists, is beyond silly. If it's broken, prove it's broken with a specific test, not assume it's broken because it broke a few years ago.

@IamdeiAm
Copy link

Please help out am facing this
On my Termux on my android phone

error: "/data/data/com.termux/files/usr/lib/node_modules/node-gyp/bin/node-gyp.js" has bad ELF magic: 23212f75
npm error code 1
npm error path /data/data/com.termux/files/usr/lib/node_modules/truffle/node_modules/bufferutil
npm error command failed
npm error command sh -c node-gyp-build

npm error A complete log of this run can be found in: /data/data/com.termux/files/home/.npm/_logs/2024-08-31T16_01_42_647Z-debug-0.log
~ $
~ $

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Something is not working properly nodejs Issue is about Node.js related stuff, including npm
Projects
None yet
Development

No branches or pull requests