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

Cannot create react-app in WSL #5669

Open
patr543a opened this issue Sep 18, 2023 · 8 comments
Open

Cannot create react-app in WSL #5669

patr543a opened this issue Sep 18, 2023 · 8 comments
Labels
bug Something isn't working needs investigate Needs to be investigated to find the root cause

Comments

@patr543a
Copy link

What version of Bun is running?

1.0.2+37edd5a6e389265738e89265bcbdf2999cb81a49

What platform is your computer?

Microsoft Windows NT 10.0.19045.0 x64

What steps can reproduce the bug?

  1. Start WSL
  2. Run bun create react-app reactAppName
  3. Error should occur

What is the expected behavior?

It creates the app without any errors

What do you see instead?

I get an error that says:

Could not start an npm process in the right directory.

The current directory is: /mnt/c/Users/pathToFolder/reactAppName
However, a newly started npm process runs in: C:\Users\pathToFolder\reactAppName

This is probably caused by a misconfigured system terminal shell.
error: "create-react-app" exited with code 1 (SIGHUP)

Additional information

the termial is at a different path in wsl than what it's trying to access, the final location is the same due to how wsl works but the result is that npm thinks it's different causing issues.

@patr543a patr543a added the bug Something isn't working label Sep 18, 2023
@huynhdev24
Copy link

Bun is currently a hot trend so there will be many people using it and can be used for production so there will be a lot of issues so hopefully bun will be even stronger in the future.

@isaac-gros
Copy link

I think I had the same issue once, but it wasn't related to Bun. As long as you create your projects inside your WSL directories and the npm command is called from your WSL, you shouldn't have any problem.

I tried to reproduce your error, but didn't have any problems as I ran bun create react-app and npm run start using WSL only. But I had a similar error when I tried to run npm run start using Powershell.

Thus, try to run npm run start using your WSL (via Windows Terminal or your Linux distro CLI). You can access your Windows files from your WSL using cd /mnt/c/Users/pathToFolder/reactAppName and then npm run start.

Hope it helps !

@patr543a
Copy link
Author

I think I had the same issue once, but it wasn't related to Bun. As long as you create your projects inside your WSL directories and the npm command is called from your WSL, you shouldn't have any problem.

I tried to reproduce your error, but didn't have any problems as I ran bun create react-app and npm run start using WSL only. But I had a similar error when I tried to run npm run start using Powershell.

Thus, try to run npm run start using your WSL (via Windows Terminal or your Linux distro CLI). You can access your Windows files from your WSL using cd /mnt/c/Users/pathToFolder/reactAppName and then npm run start.

Hope it helps !

The issue is not that, the issue is bun is starting npm in windows path and not Linux path so npm fails because current path (linux) doesn't match the path it was told (the windows path)

@isaac-gros
Copy link

The issue is not that, the issue is bun is starting npm in windows path and not Linux path so npm fails because current path (linux) doesn't match the path it was told (the windows path)

Ok, then where is located your npm command when you run which npm in your WSL ? I'm using NVM and I got this result :

/home/Username/.nvm/versions/node/v16.14.2/bin/npm

@isaac-gros
Copy link

Any update @patr543a ?

@patr543a
Copy link
Author

Any update @patr543a ?

This is what i get
/mnt/c/Program Files/nodejs//npm

@isaac-gros
Copy link

This is what i get
/mnt/c/Program Files/nodejs//npm

Okay, I'm pretty sure the problem lie in your Node installation on your WSL because npm command calls Windows Node.js installation and not the WSL one. You should try to reinstall Node.js on your WSL using a version manager like NVM. Windows provided a tutorial on how to do it : https://learn.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-wsl

This thread can also help you : microsoft/WSL#1896

@Electroid Electroid added the needs investigate Needs to be investigated to find the root cause label Oct 28, 2023
@ToeJammm
Copy link

ToeJammm commented Feb 9, 2024

@patr543a I am having the same exact issue in my vscode WSL terminal. Did you ever fix your problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs investigate Needs to be investigated to find the root cause
Projects
None yet
Development

No branches or pull requests

5 participants