I'm using yarn
creating a new projet with create-react-app produces an error and the resulting projet is not working
create-react-app testProject should finish without any errors and create a working project
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)
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
[email protected] /home/beac0n/dev/testProj
└── [email protected]node -v:> $ node -v
v7.4.0npm -v:> $ npm -v
4.1.1> $ yarn --version
0.19.1Then, specify:
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
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
@beac0n Have you made sure to set up your PATH?
_Add export PATH="$PATH:
yarn global bin" to your profile (this may be in your .profile, .bashrc, .zshrc, etc.)_
@lmcjt37 : Yes, the yarn command works:
> $ whereis yarn
yarn: /usr/bin/yarn
Either the yarnpkg command (symlink?) was not installed when I executed yaourt -S yarn
or the yarnpkg command was put somewhere else, which would be really strange.
@beac0n Seems it could be related to this issue #1363 where a fix has been merged in to add the alias of yarnpkg for yarn. Maybe this will solve your issue?
@lmcjt37 : https://github.com/yarnpkg/yarn/commit/cefa9a368dd3df1a1f1ecd9e50de9c5fabefbc92
so it should be fixed in yarn v0.20.0-0.
@beac0n Looks like that should also fix the alias issue and easier to just bump your version to test.
@lmcjt37 : since I have fixed it for my system (for now). I would like to wait until yarn is upgraded to v0.20.0 in the AUR package. What should we do with this issue until then?
@beac0n Think it needs to be parked until this issue can be resolved and confirmed based on the above.
I’m not sure what you mean by “yarn 0.20”. The commit in question existed since 0.16.
I don't know why yarnpkg alias is not working on your system.
Please file an issue in Yarn repo about it.
We should fix CRA to not crash when this happens, and instead fall back to npm.
Which version of create-react-app are you using?
@gaearon :
I’m not sure what you mean by “yarn 0.20”. The commit in question existed since 0.16.
you're right. I looked at the wrong version number :-| (sorry about that).
Which version of create-react-app are you using?
$ create-react-app --version
1.0.2
The linked issue was referencing 1.0.3, not 1.0.2: https://github.com/facebookincubator/create-react-app/issues/1363#issuecomment-271323481.
@gaearon upgrading to create-react-app 1.0.3 removed the error. create-react-app is using npm instead of yarnpkg. It's still strange that the alias to yarnpkg is not working
Yea, that would be the Yarn issue I guess. Not sure why it happens. I hope it gets resolved!
Maybe it's possible the Arch Linux package doesn't come with a yarnpkg executable, just a yarn 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.
That would explain it!
For what it's worth, Facebook laptops seem to be set up with yarn working but not yarnpkg, so if you are running create-react-app on a FB-provisioned laptop you will need to update to create-react-app version 1.0.3 or later. Leaving this here for future FB employees that run into this ;-)
Haha I just ran into this, thanks 😄
Fixed it by making my own alias from yarnpkg to yarn.
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
Want to file a new issue? If you provide many details we might be able to help. Hard to track in an old issue though.
The problem as described in this existing issue still exists, there is no additional new information to add to it. The issue simply still persists as it was reported. Here are the package versions on my macOS highSierra, I am still encountering this issue today: