I have a scripts in package.json
"scripts": {
"start": "babel-node src/server/main.js --presets es2015,stage-2",
"dev": "webpack -d --watch",
"build": "babel src/server -d dist",
"serve": "node src/server/main.js"
},
When I use npm, I use command npm run dev or npm start, everything work fine.
When I try yarn, I use command yarn run dev or yarn start, it's not working.
Some message error:
yarn run v0.15.1
sh: babel-node src/server/main.js --presets es2015,stage-2: No such file or directory
error Command failed with exit code 127.
info Visit http://yarnpkg.com/en/docs/cli/start for documentation about this command.
yarn run v0.15.1
$ "webpack -- -d --watch"
sh: webpack -- -d --watch: command not found
error Command failed with exit code 127.
info Visit http://yarnpkg.com/en/docs/cli/run for documentation about this command.
How to fix it? Please help me?
For the interim @kensupermen, do you have babel, babel-node, and webpack installed as dev dependencies for the project? If not, it's better to do that than relying on those packages being globally installed. Also, it should fix your problem with yarn not finding the commands.
Fixed via #809.
I know that this was supposed to be fixed in #809 but I still can't run scripts. I use nvm so maybe it has something to do with it?
I tried in two different projects with the same results
Example: in one of the projects I have a simple npm run clean which is just rm -rf ./www and here is the output using 0.15.1
$ yarn run clean
yarn run v0.15.1
$ "rm -rf ./www" # this is still part of yarn output, not a new command
sh: rm -rf ./www: No such file or directory
error Command failed with exit code 127.
info Visit http://yarnpkg.com/en/docs/cli/run for documentation about this command.
I am facing the same problems please let me know when the fix is released
$ yarn start
yarn start v0.15.1
$ "node server/devServer.js"
sh: node server/devServer.js: No such file or directory
error Command failed with exit code 127.
info Visit http://yarnpkg.com/en/docs/cli/start for documentation about this command.
I find wrapping the command in quotes works.
So I change:
"lint": "eslint \"static/src/**/**/*.js\""
to:
"lint": "\"eslint static/src/**/**/*.js\""
Of course this is awful to write and it's not compatible with npm run.
@paltman and @neelbommisetty I found the same issue today and the quotes workaround suggested worked just fine. This was on Yarn 0.15.1. I was curious as to whether the fix was included in a newer version so set about upgrading yarn (installed via brew). I had trouble at first as brew complained about node being unlinked, but once this was resolved by following brew doctor's instructions, I was able to upgrade yarn to 0.16.0. I can confirm the official fix is in place in this version, so the quotes workaround was no longer needed. I use n for node version management, not sure if that is confusing matters with yarns dependency on node in brew.
I earlier installed yarn via npm. and i faced this bug. But later i uninstalled and installed via installation script the same version 0.15.1 and the scripts started working
That's so strange, maybe best to avoid installing via npm then - which makes sense as it is intended as an npm replacement anyway.
This is fixed for me on 0.16.1 & installed through npm.
Thanks @ahmedelgabri
I updated yarn on 0.16.1 and It's working fine
Most helpful comment
I find wrapping the command in quotes works.
So I change:
to:
Of course this is awful to write and it's not compatible with
npm run.