-
Notifications
You must be signed in to change notification settings - Fork 29k
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
npm on Windows fails with module not found for Node.js 22.0.0 #52682
Comments
For your information, I have the same problem on my Windows machine, so it's not just a problem with Github actions
|
I am also experiencing this. |
I'm currently not able to reproduce on my Windows machine. I tried:
|
@targos When I saw that it didn't work, I uninstalled Node, then did a clean install, with the same installer file. (after cleaning up all the cache files etc) I then tried activating corepack and installing npm via corepack ( After checking, it seems that the Also, I've changed the |
@targos I've just tried installation via Volta, and npm works correctly. |
I don't know how to reproduce on my Windows system but it seems indeed to be a general issue on GitHub actions (which download the binary from https://nodejs.org/dist/v22.0.0/node-v22.0.0-win-x64.7z): https://github.com/nodejs/citgm/actions/runs/8831148407/job/24245743480?pr=1056 |
have the same issue |
The main difference I see between v20/v21 and v22 is the presence of /cc @nodejs/npm @lukekarrys |
Also /cc @StefanStojanovic. I'm trying to find a simple reproduction but I hit another problem. Here are the steps I took:
|
Then I installed a global node.exe with Volta and hit another (still different, but similar) issue:
Maybe the problem is that the |
This appears to be a problem w/ the base node installation in windows itself. A related issue is npm/cli#6971 It seems that in some installations npm does not end up where it belongs? Or is missing directories? |
No, it tries to ask windows where node.exe is
It then looks to the parent folder of the node executable and starts looking for npm there
That's why this is happening
There is no |
|
Yes. |
npm has to make an assumption that Is there another node.exe that is in the path? How do these strings materially differ, shouldn't they be the same? It looks like that difference is the root cause here. We'll keep this issue open to track the work instead of making duplicates. While we're on the subject however, it appears that this |
This may represent a larger issue that has to date gone unnoticed. What npm is trying to make sure of is that If |
In the short term, we'll update the |
I think this is a mistake in the ps1 scripts that
I would be curious if anyone knows how to fix the issue with digitally signing the ps1 scripts. I don't think it's directly related to this issue, but v22 is the first time these scripts are included in the Node installer. I'm not sure if this is something that should be fixed on the npm or node side. |
|
As for signing, Node.js signs assets it produces (the |
This is the expected error if the image just didn't set the path |
https://github.com/actions/node-versions/releases/tag/22.1.0-8926142033 fixes things in GitHub Actions for me. - uses: actions/setup-node@v4
with:
node-version: 22.1 |
This issue is easy to reproduce if one creates a windows docker container and happens to install nodejs via chocolatey |
INSTALL THE LATEST VERSION v22.1.0 NODEJS , THAT WOULD FIX THE BUG GUYS ! I TRIED AND GOOD TO USE ! |
This issue has been fixed in the latest npm 10 and Node 22 releases. I'm going to close this but open a new issue for something we found from debugging this: The Windows installer places the npm shim files in a location that takes precedence over the global npm packages directory. So subsequent npm installs via This is only an issue when there exists a bug in the shim files like in this issue. In that scenario installing a new version of npm won't fix the shim files, which feels like an oversight because those files live in the npm repository. |
This issue has resurfaced in Node.js 20.13.0 which was released earlier today. |
I get this error in vscode in Powershell running any npm or npx command like:
But running in Command Prompt works:
Spent 8 hours debugging removing/reinstalling/fixing with installer, restarting vscode/computer, removing adding suggested path variables, etc before realizing the command worked in Command Prompt but not Powershell. |
@timjbrown Your issue is fixed in the latest versions of Node.js and npm. |
This commit addresses the issue where Windows GitHub runners experience failures due to unstable Node.js releases, particularly version 20.13.0, as detailed in nodejs/node#52884 and nodejs/node#52682. The 'check-latest' input in the 'setup-node' GitHub Action forces every job to verify and potentially install the latest Node.js version. This input was originally introduced to reduce maintenance efforts to keep CI/CD setup up-to-date with the latest Node version. However, the necessity to always run the latest Node.js version is not critical for the CI/CD setup. Additionally, it causes increate network requests and may inadvertently introduce unstable Node.js versions. This commit removes the 'check-latest' option to prevent the immediate adoption of new, potentially unstable Node.js releases, thus simplifying the CI/CD pipeline. This keeps CI/CD process is robust and predictable, reducing the chances of unexpected disruptions in service deployment.
This commit addresses the issue where Windows GitHub runners experience failures due to unstable Node.js releases, particularly version 20.13.0, as detailed in nodejs/node#52884 and nodejs/node#52682. The 'check-latest' input in the 'setup-node' GitHub Action forces every job to verify and potentially install the latest Node.js version. This input was originally introduced to reduce maintenance efforts to keep CI/CD setup up-to-date with the latest Node version. However, the necessity to always run the latest Node.js version is not critical for the CI/CD setup. Additionally, it causes increased network requests and may inadvertently introduce unstable Node.js versions. This commit removes the 'check-latest' option to prevent the immediate adoption of new, potentially unstable Node.js releases, thus simplifying the CI/CD pipeline. This keeps CI/CD process is robust and predictable, reducing the chances of unexpected disruptions in service deployment.
* test: update CI node versions * Update npm-test.yml * revert changes to quotes * 22.0 broken on windows nodejs/node#52682
There is a way to fix it. At least that's how I fixed it. Run CMD and put this command: npm i -g npm. It will take few seconds to install and then you will face this issue again. |
PS C:\Users\Scratch> node bot.js Error: Cannot find module 'C:\Users\Scratch\bot.js' Node.js v20.16.0 any way to fix this?? |
@Rj979 Same. same version worked on my mac, but not windows. I tried installing v22, v18, v20 with Volta and msi and choco. All didn't work. Wasted 3 hrs. Nice... I should've gave up and stuck to mac instead... |
@Rj979 Nevermind. I fixed it. And lesson learnt for me. Because I used a "&" in my project path and it wasn't able to start properly. Try and properly uninstall version 20.16.0. Alongside with its npm file. And I reinstalled version 22.6.0 using the msi file. And it worked! Note: sorry for doubting node js, And i learnt a lesson to never used "&" in windows again |
I'm having the same issue:
The
The node has been installed from the official website. To resolve the issue I had to rerun the node installation via Chocolatey. |
Version
22
Platform
Windows
Subsystem
No response
What steps will reproduce the bug?
npm install command is enough to reproduce the issue.
Example workflow: https://github.com/CycloneDX/cdxgen/actions/runs/8823813113/job/24236408405#step:10:18
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
No response
What do you see instead?
Additional information
No response
The text was updated successfully, but these errors were encountered: