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

Error: spawn yarnpkg ENOENT #1429

Closed
beac0n opened this issue Jan 23, 2017 · 20 comments
Closed

Error: spawn yarnpkg ENOENT #1429

beac0n opened this issue Jan 23, 2017 · 20 comments

Comments

@beac0n
Copy link

beac0n commented Jan 23, 2017

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:

  1. 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
  2. node -v:
    > $ node -v v7.4.0
  3. npm -v:
    > $ npm -v 4.1.1
    > $ yarn --version 0.19.1

Then, specify:

  1. Operating system: Arch Linux
  2. 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

@lmcjt37
Copy link

lmcjt37 commented Jan 23, 2017

@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.)

@beac0n
Copy link
Author

beac0n commented Jan 23, 2017

@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.

@lmcjt37
Copy link

lmcjt37 commented Jan 23, 2017

@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?

@beac0n
Copy link
Author

beac0n commented Jan 23, 2017

@lmcjt37 : yarnpkg/yarn@cefa9a3
so it should be fixed in yarn v0.20.0-0.

@lmcjt37
Copy link

lmcjt37 commented Jan 23, 2017

@beac0n Looks like that should also fix the alias issue and easier to just bump your version to test.

@beac0n
Copy link
Author

beac0n commented Jan 23, 2017

@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?

@lmcjt37
Copy link

lmcjt37 commented Jan 23, 2017

@beac0n Think it needs to be parked until this issue can be resolved and confirmed based on the above.

@gaearon
Copy link
Contributor

gaearon commented Jan 23, 2017

I’m not sure what you mean by “yarn 0.20”. The commit in question existed since 0.16.

@gaearon
Copy link
Contributor

gaearon commented Jan 23, 2017

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?

@beac0n
Copy link
Author

beac0n commented Jan 23, 2017

@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

@gaearon
Copy link
Contributor

gaearon commented Jan 23, 2017

The linked issue was referencing 1.0.3, not 1.0.2: #1363 (comment).

@beac0n
Copy link
Author

beac0n commented Jan 23, 2017

@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

@beac0n beac0n closed this as completed Jan 23, 2017
@gaearon
Copy link
Contributor

gaearon commented Jan 23, 2017

Yea, that would be the Yarn issue I guess. Not sure why it happens. I hope it gets resolved!

@Daniel15
Copy link
Member

Daniel15 commented Jan 24, 2017

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.

@gaearon
Copy link
Contributor

gaearon commented Jan 24, 2017

That would explain it!

@lacker
Copy link
Contributor

lacker commented Feb 3, 2017

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 ;-)

@gaearon
Copy link
Contributor

gaearon commented Feb 14, 2017

Haha I just ran into this, thanks 😄
Fixed it by making my own alias from yarnpkg to yarn.

@itwasmattgregg
Copy link

itwasmattgregg commented Jun 30, 2017

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

@gaearon
Copy link
Contributor

gaearon commented Jun 30, 2017

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.

@yilinglu
Copy link

yilinglu commented Oct 24, 2017

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:

yarn@0.24.5
npm@5.5.1
create-react-app@1.4.1

@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants