I'm having trouble using the run
command provided by yarn
, Facebook's package manager for JavaScript.
Currently in my package.json
file I have the following for my scripts
object.
"scripts": {
"lint": "./node_modules/.bin/eslint --ignore-pattern dist ."
}
When I run the following command, it works as expected, npm run lint
. However, when I run the script from yarn
with yarn run lint
I receive the following error.
Petesta :: λ -> ~/Git/yarn yarn run lint
yarn run v0.15.1
$ "./node_modules/.bin/eslint --ignore-pattern dist ."
sh: ./node_modules/.bin/eslint --ignore-pattern dist .: 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.
The ./node_modules/.bin
directory is on my $PATH
and I did notice that if you have an executable like date
or pwd
then yarn run some_script_on_date
will work as expected.
One way to get this to work is to create a separate shell file containing the command you're trying to execute. Let's call it ./scripts/lint.sh
.
#!/bin/bash
./node_modules/.bin/eslint --ignore-pattern dist .
And then run this command on the file chmod +x ./scripts/lint.sh
Now in your scripts
object add the following line.
"new_lint": "./scripts/lint.sh"
And now yarn run new_lint
will run as expected.
Am I missing something or is this how calling scripts in yarn
needs to be done? I would like for to run the command like with npm
.