-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[BUG] all commands fail: TypeError: LRU is not a constructor
#6785
Comments
Can you try npm@10.1.0 which is the latest versions? Also how did you download this version of npm? npm view npm --json versions
[
...
"10.0.0-pre.0",
"10.0.0-pre.1",
"10.0.0",
"10.1.0"
] |
@lukekarrys thank you and my apology for opening this issue here. This should have been opened at the arch package location instead https://gitlab.archlinux.org/archlinux/packaging/packages/npm/-/blob/main/PKGBUILD?ref_type=heads respectfully, I will close this issue |
@iambumblehead I've been experiencing the same issue on all of my Arch installations as well after upgrading to npm 10. Downgrading to 9.8.1 is a temporary workaround. Have you already reported the issue to the Arch maintainer? I couldn't find anything here https://bugs.archlinux.org/?project=1&string=npm. I can open a ticket on the Arch side as well if you prefer. |
@blacklight please open a ticket :) I do not have an account there and did not open a ticket |
@iambumblehead ok FYI I've filed a bug report on Arch here https://bugs.archlinux.org/task/79693 |
thanks. toolybird's comment un-necessarily rude |
@iambumblehead I've found the culprit and a solution - see comment on the Arch Linux thread. Long story short, the error most likely happens when you have (or had at some point) an old version of semver installed - either an old semver package or something installed via Uninstalling npm+semver, removing |
@blacklight yes that works thank you! $ sudo pacman -R npm semver node-gyp
$ sudo rm -rf /usr/lib/node_modules/npm/node_modules/semver
$ sudo pacman -S npm semver
$ npm --version
10.1.0 |
I'm curious, how tf did you find that out? |
The above fix does not work now. After The command npm --version gives TypeError: LRU is not a constructor Node.js v21.5.0 |
Why would you install an npm package via pacman? use npm. |
Installing packages via When If they were installed via As a general advice, global packages should always be installed through the system package manager, if they are available.
If the error doesn't come from My way of pinpointing the culprit usually works, but it's a bit cumbersome - not sure if there's a smarter way of telling which dependencies weren't installed via
|
I backed up each of the above folder and removed it. then pacman -S npm accepted the semver and node-gyp dependencies and all installed. Now npm --version fails again, now with: /usr/lib/node_modules/npm/lib/es6/validate-engines.js:31 Error: Cannot find module 'nopt'
Node.js v21.5.0 |
Ah, I installed nodejs-nopt and now it works! Thank you. The folders I had backed up are: corepack, root, vdx and node-gyp, nopt, npm, semver which where installed again by pacman. I guess these are needed... how do I install them with pacman (I mean corepack, root, vdx)? |
It may be that they are no longer required by recent versions of |
OK. Great! |
I had a few other modules that did not work after having reinstalled npm and semver as recommended by @blacklight . I also needed to manually delete the
Note: This obviously nukes your globally installed node_modules, but I wanted a clean state to work off of |
What is the workaround for windows? |
Hello, Error is in this line: https://github.com/npm/node-semver/blob/ec49cdcece9db0020d6829b246681ff65a393644/classes/range.js#L201 It has been introduced in semver 7.3.3. The new version 7.6.1 is released and will solve the problem. Related MR here: Solution is to upgrade to 7.6.1 or downgrade to 7.3.2 If you want to downgrade add below to your package.json: NPM:
Yarn:
Hope it helps. |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
npm --version and other commands print a runtime error
Expected Behavior
npm commands should not fail with a runtime error
Steps To Reproduce
Environment
The text was updated successfully, but these errors were encountered: