
パスは自動で追加されるので、気にせずそのまま実行ファイル名を指定してしまって大丈夫。
例えばこれ↓だけで node_modules/.bin/tsc が(あれば)実行されます。
{
"scripts": {
"build": "tsc"
}
}
同様に npx も書く必要なし。プロジェクトの外、グローバルにインストールされたものを呼び出すってなら必要だけど、ローカルにインストールするべきですよ。
ドキュメントの記載
In addition to the shell’s pre-existing
PATH,npm runaddsnode_modules/.binto thePATHprovided to scripts. Any binaries provided by locally-installed dependencies can be used without thenode_modules/.binprefix.
シェル既存の PATH に加えて、npm run は node_modules/.bin を PATH へ追加してスクリプトへ提供します。ローカルインストールされた依存のバイナリーは、node_modules/.bin 接頭辞なしで利用可能です。
だそうです。