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

Installing Windows NodeJS causes problems when running npx and npm in WSL #37503

Closed
jpchabot opened this issue Jan 5, 2025 · 1 comment
Closed
Labels
goal: completeness (Experiment label) Issues about content missing important/relevant details. needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.

Comments

@jpchabot
Copy link

jpchabot commented Jan 5, 2025

MDN URL

https://developer.mozilla.org/en-US/docs/Learn_web_development/Getting_started/Environment_setup/Command_line

What specific section or headline is this issue about?

No response

What information was incorrect, unhelpful, or incomplete?

After installing WSL and VSCode + WSL integration I installed NodeJS with the Windows .msi installer. I then installed Prettier and ran into issues when trying to run npx prettier, it was giving an "invalid URL" error. And running npx only would open cmd.exe instead of staying in bash. I had issues with npm as well.

My first step to fix was uninstalling NodeJS from Windows and reinstalling it in WSL with apt. Second step was adding this (AI-suggested fix) to ~/.bashrc because my PATH was still messed up:

export PATH=$(echo $PATH | sed -e 's|/mnt/c/Program Files/nodejs:||' -e 's|/mnt/c/Users/bledk/AppData/Roaming/npm:||')

What did you expect to see?

Document should suggest to install NodeJS through WSL, not Windows installer.

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details
@jpchabot jpchabot added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jan 5, 2025
@caugner caugner added the goal: completeness (Experiment label) Issues about content missing important/relevant details. label Jan 7, 2025
@hamishwillee
Copy link
Collaborator

Thanks @bledking. It is perfectly valid to have nodejs installed in Windows and WSL - personally I work in windows most of the time, and move to WSL2 when it is needed for the toolchain I am interested in. I use nvm to manage node in both environments, but I have previously used the msi installer without any issues alongside VSCode, command line, prettier etc. This is the first I have seen of this issue.
The two environments are separate and shouldn't bleed into each other as you are seeing. I don't see how they can.

We can't accept the suggested fix because many users will have no interest in WSL shouldn't be pushed down that path. I'm not sure the problem would reproduce for anyone else either, since I haven't seen it myself or seen reports of issues (though there may be some).

I'm therefore going to close this since at this point it looks like a "your setup" issue - and if it is broader than that, then it should be addressed through the various toolchain vendors.

Note though we might accept a PR that replaces the msi installation with NVM or FNM based installation of Node, since once users get a little of the way down the web development path they will likely need multiple node versions. That might not fix the problem though, since we don't know the root cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
goal: completeness (Experiment label) Issues about content missing important/relevant details. needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.
Projects
None yet
Development

No branches or pull requests

3 participants