Facebook の JavaScript 用パッケージ マネージャであるrun
が提供するコマンドを使用できません。yarn
現在、私のpackage.json
ファイルには、scripts
オブジェクト用に次のものがあります。
"scripts": {
"lint": "./node_modules/.bin/eslint --ignore-pattern dist ."
}
次のコマンドを実行すると、期待どおりに動作しnpm run lint
ます。ただし、スクリプトをyarn
withから実行するとyarn run lint
、次のエラーが表示されます。
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.
./node_modules/.bin
ディレクトリは私のものであり、または$PATH
のような実行可能ファイルがあれば、期待どおりに機能することに気付きました。date
pwd
yarn run some_script_on_date
これを機能させる 1 つの方法は、実行しようとしているコマンドを含む別のシェル ファイルを作成することです。と呼びましょう./scripts/lint.sh
。
#!/bin/bash
./node_modules/.bin/eslint --ignore-pattern dist .
そして、ファイルに対してこのコマンドを実行しますchmod +x ./scripts/lint.sh
scripts
オブジェクトに次の行を追加します。
"new_lint": "./scripts/lint.sh"
そして今yarn run new_lint
、期待どおりに実行されます。
何か不足していますか、それともスクリプトを呼び出すyarn
必要があるのですか? のようにコマンドを実行したいと思いnpm
ます。