Yarn: ENOENT once.js on yarn install

Created on 14 Mar 2017  Â·  32Comments  Â·  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?
A bug

What is the current behavior?
A fresh global install of yarn fails to yarn install in a project due to the error described here.

I get this error:

Error: ENOENT: no such file or directory, open '/Users/cmccarthy/.nvm/versions/node/v6.10.0/lib/node_modules/yarn/node_modules/end-of-stream/node_modules/once/once.js'

This was working yesterday afternoon and it looks like end-of-stream pushed an update to 1.4.0 just 4 hours ago that is causing this.

If the current behavior is a bug, please provide the steps to reproduce.
In any node app:

npm install -g yarn
yarn install

What is the expected behavior?
yarn install works

I think yarn could pin end-of-stream to 1.2.0 to fix it.

Please mention your node.js, yarn and operating system version.
node 6.10.0 and npm 3.10.10

Most helpful comment

We ran into this issue as well -- we worked around it by specifying a yarn version when installing yarn via npm:

npm install -g [email protected]
yarn install

All 32 comments

Just looking at the same issue like "huh?"

It's a hack but if anyone is stuck with a failing CI due to this you can do this to get around it for now:

export BACK_TO_WORKSPACE=$(pwd)
cd $(npm config get prefix)/lib/node_modules/yarn/node_modules/end-of-stream
npm install once
cd $BACK_TO_WORKSPACE

same problem here

Floating versions and non-deterministic builds appear to have broken the internet again. I still wonder how this happens with yarn, though.

Same issue. Hack did not help.
end-of-stream issues

:(

I'm not sure what the exact issue was, but I was using yarn ~0.18.x or so, and upgraded to 0.21.3 and my problems seem to be resolved. Have no idea why, but maybe worth trying if you're shooting in the dark like i was to fix this anyway.

I'm seeing this when yarn is installed via npm. Has anyone seen this error when other methods of installation are used? (To @jsight's comment, the problem is that we can't install yarn with yarn itself.)

@jsight yarn discourages installing via npm since they cannot guarantee the dep tree.

@AlexLandau I doubt the other recommended methods of installing yarn have this issue.

@AlexLandau - Ah, good point. I guess that is our problem as well. Maybe the tool could emphasize this somehow?

We ran into this issue as well -- we worked around it by specifying a yarn version when installing yarn via npm:

npm install -g [email protected]
yarn install

Installing yarn properly fixed it here (rpm install instead of via npm).

"Installing yarn properly fixed it here (rpm install instead of via npm)."

I'm running into this using the Gradle node plugin. Not sure, but seems that might be using npm. Any suggestions for working around that?

@zman2245 - There is a tarball available here: https://yarnpkg.com/en/docs/install#alternatives-tab

Perhaps Gradle could be configured to use it?

Why not use an npm-shrinkwrap.json file?

I was able to get my Jenkins builds working again by specifying [email protected] in the global package install instead of just yarn

screen shot 2017-03-16 at 10 25 44 am

Jenkins does use npm to install, so it seems that specifying the version will work, from the Jenkins console log:

```$ /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_7.7.1/bin/npm install -g [email protected]
/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_7.7.1/bin/yarn -> /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_7.7.1/lib/node_modules/yarn/bin/yarn.js
/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_7.7.1/bin/yarnpkg -> /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_7.7.1/lib/node_modules/yarn/bin/yarn.js

@zman2245 Can you try specifying the version on install?

@doublesharp Can confirm that specifying @0.22.0 fixes our CI builds.

@llwt same here

I can confirm that 0.22.0 fixes my issue.

Working so far for my CI environment as well.

This was the fix for me too...

npm install -g [email protected]
yarn install

Thanks!

I can confirm that the fix with forcing to 0.22.0 works on our Jenkins server too

I hope 0.22.0 will be released soon

Can this stop breaking please? So annoying. Gradle and Ant installs never break for me.

The docs explicitly call out that installing yarn via npm cannot be guaranteed. That's the very reason why yarn existed.

Please lock this thread.

@jasonmit - +1 - although I wonder if there could be a warning when it is installed this way? It seems to be a common cause of spurious issue reports.

Then remove yarn from npm if it's not supposed to be installed that way.

It is not an installation issue. I installed Yarn v0.21.3 using the windows installer and started encountering this issue after I did a "yarn upgrade".

What.. the... heck.

Yarn on Mac OS, installed via the official instructions (brew install yarn). Version 0.21.3, totally failing on yarn init, even yarn --version:

/usr/local/Cellar/yarn/0.21.3/libexec/lib/node_modules/yarn/bin/yarn.js:61
      throw err;
      ^

Error: ENOENT: no such file or directory, open '/usr/local/Cellar/yarn/0.21.3/libexec/lib/node_modules/yarn/node_modules/end-of-stream/node_modules/once/once.js'
    at Error (native)
    at Object.fs.openSync (fs.js:641:18)
    at Object.fs.readFileSync (fs.js:509:33)
    at Object.Module._extensions..js (module.js:578:20)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/local/Cellar/yarn/0.21.3/libexec/lib/node_modules/yarn/node_modules/end-of-stream/index.js:1:74)

If I remove the brew version and install via npm i -g yarn (same version, mind you), it works totally fine.

I'm also seeing this on yarn from brew. The odd thing is that it worked, then I uninstalled it (I needed there to not be a global yarn to fix a bug in our build toolchain), and when I installed it, it stopped working.

Same tarball, since brew checks the sha, must the the formula itself.

EDIT: Reseting to this commit and reinstalling solves it: https://github.com/Homebrew/homebrew-core/blob/f92d1c1bb5165f56c6fcf2c6d7e189f4815564bc/Formula/yarn.rb

The diff between that and HEAD:
image

Repro for fix:

$ brew uninstall yarn
$ cd `brew --repo`/Library/Taps/homebrew/homebrew-core
$ git checkout f92d1c1bb5165f56c6fcf2c6d7e189f4815564bc
$ HOMEBREW_NO_AUTO_UPDATE=true brew install yarn

If anyone sees this again, can you please try deleting the .roadrunner.json from the Yarn cache directory? I suspect Roadrunner is doing something strange.

I think the issue I'm seeing might be with the included npm with the version of node on brew (7.7.4 yesterday, 7.8.0 now), and not so much a specific dependency anymore, since it actually install the distributed tarball. I've sent a PR to homebrew dropping the usage of npm install to install

In my experience, the best way to get around this is just run rm '/usr/local/bin/node' then re install node from nodejs.org. It always does the trick for me when I accidentally start messing with yarn in a project I'm using npm on.

  • So rm '/usr/local/bin/node' removes nodejs from your local environment.
  • Re-installing it on their website is an order of magnitude easier than letting homebrew do a suplex on your symlinks and then piledrive you into dependency hell.
Was this page helpful?
0 / 5 - 0 ratings