question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
eclectocommented, Feb 8, 2021

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

5reactions
ezhikovcommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm start hangs, does not sync changes (create-react-app on ...
I am using Ubuntu 20.04 in WSL. When I run: npx create-react-app helloworld cd helloworld npm start. I get: helloworld3@0.1.0 start / ...
Read more >
Install React on Windows Subsystem for Linux - Microsoft Learn
This guide will walk through installing React on a Linux distribution (ie. Ubuntu) running on the Windows Subsystem for Linux (WSL) using ...
Read more >
Developing in WSL - Visual Studio Code
When VS Code Remote is started in WSL, no shell startup scripts are run. This was done to avoid issues with startup scripts...
Read more >
react-scripts: command not found error [Solved] | bobbyhadz
Run the `npm install react-scripts` command to solve the react-scripts: command not found error. If necessary delete your `node_modules` directory and your ...
Read more >
How To Hot Reload Auto Refresh React App On Wsl
If you're working on a React app on Windows using Windows Subsystem for Linux (WSL), you might find that your app does not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found