oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.12k stars 2.77k forks source link

Cannot create react-app in WSL #5669

Open patr543a opened 1 year ago

patr543a commented 1 year ago

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.

huynhdev24 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Any update @patr543a ?

patr543a commented 1 year ago

Any update @patr543a ?

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

isaac-gros commented 1 year ago

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 : https://github.com/microsoft/WSL/issues/1896

ToeJammm commented 9 months ago

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