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

'react-scripts start' does not work on linux (WSL) #9644

Closed
Asim-Sheikh opened this issue Sep 14, 2020 · 8 comments
Closed

'react-scripts start' does not work on linux (WSL) #9644

Asim-Sheikh opened this issue Sep 14, 2020 · 8 comments

Comments

@Asim-Sheikh
Copy link

Describe the bug

On linux (WSL) npm run start fails with the following error
spawn powershell.exe ENOENT

Not sure why its trying to spawn powershell on Linux but this seem to have been introduced from version 3.0.0 of react-scripts. The workaround is to downgrade react-scripts to 2.1.8

This is reproducible on a fresh install using latest npm version 6.14.8 and latest nodejs verison 14.10.1 (also reproducible on 10.x)

Did you try recovering your dependencies?

Reproducible on a fresh install so unlikely its related to corrupt dependencies.

Environment

System:
    OS: Linux 4.19 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
  Binaries:
    Node: 14.10.1 - /usr/bin/node
    Yarn: Not Found
    npm: 6.14.8 - /usr/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    react: ^16.13.1 => 16.13.1 
    react-dom: ^16.13.1 => 16.13.1 
    react-scripts: 2.1.8 => 2.1.8 
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

  1. npx create-react-app hello-world
  2. cd hello-world
  3. npm run start

Note: This is reproducible at least on Linux (WSL - Ubuntu), it maybe reproducible on Linux generally but I have not tested.

Expected behavior

Compiled successfully!

You can now view hello-world in the browser.

  Local:            http://localhost:3000/
  On Your Network:  http://172.31.234.113:3000/

Note that the development build is not optimized.
To create a production build, use npm run build.

Actual behavior

Starting the development server...

events.js:291
      throw er; // Unhandled 'error' event
      ^

Error: spawn powershell.exe ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
    at onErrorNT (internal/child_process.js:464:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
    at onErrorNT (internal/child_process.js:464:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn powershell.exe',
  path: 'powershell.exe',
  spawnargs: [
    '-NoProfile',
    '-NonInteractive',
    '–ExecutionPolicy',
    'Bypass',
    '-EncodedCommand',
    'UwB0AGEAcgB0ACAAIgBgACIAaAB0AHQAcAA6AC8ALwBsAG8AYwBhAGwAaABvAHMAdAA6ADMAMAAwADAAYAAiACIA'
  ]
}

Reproducible demo

This can be reproduced on a newly created project so demo project is not relevant.

@kaioduarte
Copy link

Couldn't reproduce it on WSL

Environment Info:

  current version of create-react-app: 3.4.1
  running from /home/kds/.config/yarn/global/node_modules/create-react-app

 System:
    OS: Linux 4.19 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
  Binaries:
    Node: 12.18.4 - /usr/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.6 - /usr/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    react: ^16.13.1 => 16.13.1
    react-dom: ^16.13.1 => 16.13.1
    react-scripts: 3.4.3 => 3.4.3
  npmGlobalPackages:
    create-react-app: Not Found

@Asim-Sheikh
Copy link
Author

Couldn't reproduce it on WSL

Environment Info:

  current version of create-react-app: 3.4.1
  running from /home/kds/.config/yarn/global/node_modules/create-react-app

 System:
    OS: Linux 4.19 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
  Binaries:
    Node: 12.18.4 - /usr/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.6 - /usr/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    react: ^16.13.1 => 16.13.1
    react-dom: ^16.13.1 => 16.13.1
    react-scripts: 3.4.3 => 3.4.3
  npmGlobalPackages:
    create-react-app: Not Found

So it appears it only happens when you have windows path disabled in wsl.config via the following option:

[interop] appendWindowsPath = false

It makes sense since powershell is available on path when this option is not disabled, but don't think react-scripts should be relying on powershell being available on Ubuntu.

@stale
Copy link

stale bot commented Dec 25, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Dec 25, 2020
@ezhikov
Copy link

ezhikov commented Feb 8, 2021

Have same issue on WSL2 with newly created app and react-scripts@4.0.2

It fails only if we open default browser. If you set env variable BROWSER to none there will be no error, so I guess error is in react-dev-utils.

Edit

Jumped into rabbit hole and found that package open have hardcoded value: '/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe'. I remaped default mount point, so now /mnt/c/ is absolutely empty, hence the error. It should be fixed here, but not sure it it was released yet.

@stale stale bot removed the stale label Feb 8, 2021
@eclecto
Copy link

eclecto commented Feb 8, 2021

I was able to bandaid this by symlinking /c to /mnt/c

@addisca
Copy link

addisca commented May 31, 2021

I was able to bandaid this by symlinking /c to /mnt/c

I was also able to fix the problem this way, for anybody looking for the appropriate command:

sudo ln -s /mnt/c /c

@iansu
Copy link
Contributor

iansu commented Jun 2, 2021

Can you try the latest release and see if this has improved? If not please open a new issue.

@iansu iansu closed this as completed Jun 2, 2021
@NathanHealea
Copy link

NathanHealea commented Oct 5, 2023

I was able to bandaid this by symlinking /c to /mnt/c

I was also able to fix the problem this way, for anybody looking for the appropriate command:

sudo ln -s /mnt/c /c

Thank you for this fix. I have been struggling with getting my node project to run on WLS and happened across this entire thread.

Adding the symlink solved my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants