termux-packages
termux-packages copied to clipboard
Error on the new version of NPM
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
It tries to make a hardlink, which is not allowed on android. Same issue as in https://github.com/termux/termux-packages/issues/11293, where npm install -g package
worked as a work around
I think we should patch this, if this version of npm is what we provide
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.
@GuriZenit, we are talking about native Termux environment and not proot based distributions (including third party ones).
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.
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
It seems that [email protected]
has fixed this.
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?
Emmm... It seems to work on Bluestacks, but not on my real device. I will record it and report upstream.
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 :/
Use yarn
to install npm packages !
Just pushed 6b05a8e7ba0435bec9afccd6e809329a7a62c27d. 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)
So, uh, any other way to upgrade npm?
Error;-;
ERR! Can't install npm globally as it will very likely break installation of global packages using npm. See https://github.com/termux/termux-packages/issues/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
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?
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
.
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.
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 runyarn
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.
Why are you using npm when yarn is much stable than it.
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.
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?
Works for my needs. Thanks!
Why are you using npm when yarn is much stable than it.
Woah what an opinionated comment. Not sure for you, but from my own experience, for global packages npm works better. Everyone chooses what works for them, don't bomb people with opinions unless asked :p
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.
This has been fixed in https://github.com/npm/cacache/pull/195, it works now
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
You can try this: https://github.com/varxez/termux-npm-updater
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.
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
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?
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
@varxez npm is not "node package manager" 🤦 https://github.com/npm/cli#is-npm-an-acronym-for-node-package-manager