create-react-app: Error: spawn yarnpkg ENOENT
Can you reproduce the problem with latest npm?
I’m using yarn
Description
creating a new projet with create-react-app
produces an error and the resulting projet is not working
Expected behavior
create-react-app testProject
should finish without any errors and create a working project
Actual behavior
create-react-app testProject
terminates with the following error
Installing react and react-dom using yarnpkg…
events.js:160 throw er; // Unhandled ‘error’ event ^
Error: spawn yarnpkg ENOENT at exports._errnoException (util.js:1022:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32) at onErrorNT (internal/child_process.js:359:16) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9)
Environment
Run these commands in the project folder and fill in their results:
npm ls react-scripts
(if you haven’t ejected):> $ npm ls react-scripts testProj@0.1.0 /home/beac0n/dev/testProj └── react-scripts@0.8.5
node -v
:> $ node -v v7.4.0
npm -v
:> $ npm -v 4.1.1
> $ yarn --version 0.19.1
Then, specify:
- Operating system: Arch Linux
- Browser and version: Can’t start the project - getting errors:
Failed to compile.
Error in ./src/index.js Module not found: ‘react’ in /home/beac0n/dev/testProj/src
@ ./src/index.js 5:13-29
Error in ./src/App.js Module not found: ‘react’ in /home/beac0n/dev/testProj/src
@ ./src/App.js 10:13-29
Error in ./src/index.js Module not found: ‘react-dom’ in /home/beac0n/dev/testProj/src
@ ./src/index.js 9:16-36
Potential Fix
I could actually fix the issue, by executing:
sudo ln -s /usr/lib/node_modules/yarn/bin/yarn.js yarnpkg
in my /usr/bin/
directory.
It seems like create-react-app tries to use the command yarnpkg
wich was not available on my arch linux system, although I installed yarn as described here: https://yarnpkg.com/en/docs/install#alternatives-tab
I’m not sure if this is an issue with my operating system, with yarn or with create-react-app. The issue only occurs when using create-react-app
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 20 (9 by maintainers)
I’m still having this issue even on Mac. I also tried creating a yarnpkg alias to yarn. npm v5.0.0 yarn v0.24.5 create-react-app v1.3.3
Haha I just ran into this, thanks 😄 Fixed it by making my own alias from
yarnpkg
toyarn
.Maybe it’s possible the Arch Linux package doesn’t come with a
yarnpkg
executable, just ayarn
one? The Arch package is made by a third party rather than by the Yarn developers, and I’m not quite sure how it’s packaged.