Do you want to request a _feature_ or report a _bug_?
Bug
What is the current behavior?
Take the following package.json:
{
"dependencies": {
"babel-core": "6.17.0"
},
"devDependencies": {
"eslint": "3.3.1"
}
}
Running yarn install leads to the following yarn.lock https://gist.github.com/bouk/b96cf30321d696724ef926367c5af879
Yarn LS tells me the following https://gist.github.com/bouk/6514ee7102c7c386cf29f351747c8e54
If I remove node_modules and then run yarn install --production, I will end up with a situation where escape-string-regexp is missing, even though it's a dependency of babel-core, through babel-code-frame->chalk->escape-string-regexp
What is the expected behavior?
escape-string-regexp is installed
Please mention your node.js, yarn and operating system version.
Node v6.7.0
Yarn v0.15.1
macOS 10.12
Something similar seems to happen with a global npm install of yarn.
$ npm install -g gulp
$ npm install -g yarn
Then if I run yarn I get this error
$ yarn
/usr/local/lib/node_modules/yarn/bin/yarn.js:48
throw err;
^
Error: ENOENT: no such file or directory, open
'/usr/local/lib/node_modules/yarn/node_modules/chalk/node_modules/escape-string-regexp/index.js'
at Error (native)
at Object.fs.openSync (fs.js:549:18)
at Object.fs.readFileSync (fs.js:397:15)
at Object.Module._extensions..js (module.js:415:20)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/local/lib/node_modules/yarn/node_modules/chalk/index.js:2:26)
at Module._compile (module.js:409:26)
I'm guessing because escape-string-regexp was already installed as a dependency of gulp
node 4.5.0
npm 3.10.8
macOS 10.12
I have the same issue. yarn --production is confused with dev dependencies.
Workaround for now is to install all dependencies... less than ideal.
I am also getting same error while executing yarn command.
$ yarn
/usr/local/lib/node_modules/yarn/bin/yarn.js:48
throw err;
^
Error: ENOENT: no such file or directory, open '/usr/local/lib/node_modules/yarn/node_modules/chalk/node_modules/escape-string-regexp/index.js'
at Error (native)
at Object.fs.openSync (fs.js:585:18)
at Object.fs.readFileSync (fs.js:432:33)
at Object.Module._extensions..js (module.js:405:20)
at Module.load (module.js:345:32)
at Function.Module._load (module.js:302:12)
at Module.require (module.js:355:17)
at require (internal/module.js:13:17)
at Object.<anonymous> (/usr/local/lib/node_modules/yarn/node_modules/chalk/index.js:2:26)
at Module._compile (module.js:399:26)
$
Dupe of #761.
I am able to solve this issue by following given steps.
sudo npm uninstall -g yarn.yarn
.yarn-cache
.yarn-config
.yarnrc
npm cache clean (I am not sure whether this is required or not)sudo npm install -g yarn$ yarn
/usr/local/lib/node_modules/yarn/bin/yarn.js:48
throw err;
^
Error: ENOENT: no such file or directory, open '/usr/local/lib/node_modules/yarn/node_modules/chalk/node_modules/escape-string-regexp/index.js'
at Error (native)
at Object.fs.openSync (fs.js:585:18)
I am just suspecting the root cause of this is due to different node versions while installing the yarn package. i.e. when I installed yarn first time I had node v4.3.3 and later I moved to 6.3.3 and tried to execute yarn, got few errors so I uninstalled and reinstalled yarn. From this time I am getting ENOENT error while executing yarn command.
@vaikuntn What you're describing seems to be a different issue about corrupt dependencies with installing yarn. This isse (as is #761) is about Yarn installing the incorrect dependencies when running yarn install --production (without error), and then throwing an error when running a subsequent script depending on the missing dependency. The generic error just occurs when a dependency cannot be found.
@davidowens, what @vaikuntn suggested: deleting .yarn/.yarn-cache/.yarn-config fixed it for me
NOTE: nothing related to sudo was required
Yes, I just tried that and it has worked for me too. 馃憤 for not needing sudo because that make it much easier for me to get it running on the build server
please try to intall it by brew
yarn --prod is still broken for me (https://github.com/yarnpkg/yarn/issues/761#issuecomment-260975012). Is this the correct issue for it?Now that #761 is reopenend, I suggest merging this into #761 as they are about the exact same problem.
Fixed via #2116.
Most helpful comment
I am able to solve this issue by following given steps.
sudo npm uninstall -g yarnnpm cache clean(I am not sure whether this is required or not)sudo npm install -g yarnThis should solve below given issue. try executing yarn command.
I am just suspecting the root cause of this is due to different node versions while installing the yarn package. i.e. when I installed yarn first time I had node v4.3.3 and later I moved to 6.3.3 and tried to execute yarn, got few errors so I uninstalled and reinstalled yarn. From this time I am getting
ENOENTerror while executing yarn command.