プロジェクトでインストールした node_module の実行コマンドはどこ?
npm -g i
とかでいちいちグローバルなんて使ってられないし、プロジェクトの実行環境内で完結させたい。DockerとかデプロイCIとか絡んでくると特にその思いが顕著になる。
./node_modules/.bin
公式に資料が書いてある。
Executables§ When in global mode, executables are linked into {prefix}/bin on Unix, or directly into {prefix} on Windows.
When in local mode, executables are linked into ./node_modules/.bin so that they can be made available to scripts run through npm. (For example, so that a test runner will be in the path when you run npm test.)
サンプル
たまたま手元にあったLaravelで npm i した結果で確認したら、次のように用意されている。
コマンドはここから拾えば動きますね。やったね。
takuya@bookmarklets$ ls -l node_modules/.bin/ total 0 lrwxr-xr-x 1 takuya staff 18 2019-04-02 16:52 acorn -> ../acorn/bin/acorn lrwxr-xr-x 1 takuya staff 26 2019-04-02 16:52 ansi-html -> ../ansi-html/bin/ansi-html lrwxr-xr-x 1 takuya staff 19 2019-04-02 16:52 atob -> ../atob/bin/atob.js lrwxr-xr-x 1 takuya staff 32 2019-04-02 16:52 autoprefixer -> ../autoprefixer/bin/autoprefixer lrwxr-xr-x 1 takuya staff 22 2019-04-02 16:52 browserslist -> ../browserslist/cli.js lrwxr-xr-x 1 takuya staff 34 2019-04-02 16:52 cross-env -> ../cross-env/dist/bin/cross-env.js lrwxr-xr-x 1 takuya staff 40 2019-04-02 16:52 cross-env-shell -> ../cross-env/dist/bin/cross-env-shell.js lrwxr-xr-x 1 takuya staff 20 2019-04-02 16:52 cssesc -> ../cssesc/bin/cssesc lrwxr-xr-x 1 takuya staff 15 2019-04-02 16:52 errno -> ../errno/cli.js lrwxr-xr-x 1 takuya staff 25 2019-04-02 16:52 esparse -> ../esprima/bin/esparse.js lrwxr-xr-x 1 takuya staff 28 2019-04-02 16:52 esvalidate -> ../esprima/bin/esvalidate.js lrwxr-xr-x 1 takuya staff 12 2019-04-02 16:52 he -> ../he/bin/he lrwxr-xr-x 1 takuya staff 23 2019-04-02 16:52 html-minifier -> ../html-minifier/cli.js lrwxr-xr-x 1 takuya staff 31 2019-04-02 16:52 import-local-fixture -> ../import-local/fixtures/cli.js lrwxr-xr-x 1 takuya staff 25 2019-04-02 16:52 js-yaml -> ../js-yaml/bin/js-yaml.js lrwxr-xr-x 1 takuya staff 18 2019-04-02 16:52 jsesc -> ../jsesc/bin/jsesc lrwxr-xr-x 1 takuya staff 19 2019-04-02 16:52 json5 -> ../json5/lib/cli.js lrwxr-xr-x 1 takuya staff 22 2019-04-02 16:52 loose-envify -> ../loose-envify/cli.js lrwxr-xr-x 1 takuya staff 32 2019-04-02 16:52 miller-rabin -> ../miller-rabin/bin/miller-rabin lrwxr-xr-x 1 takuya staff 14 2019-04-02 16:52 mime -> ../mime/cli.js lrwxr-xr-x 1 takuya staff 20 2019-04-02 16:52 mkdirp -> ../mkdirp/bin/cmd.js lrwxr-xr-x 1 takuya staff 23 2019-04-02 16:52 multicast-dns -> ../multicast-dns/cli.js lrwxr-xr-x 1 takuya staff 36 2019-04-02 16:52 parser -> ../@babel/parser/bin/babel-parser.js lrwxr-xr-x 1 takuya staff 27 2019-04-02 16:52 prettier -> ../prettier/bin-prettier.js lrwxr-xr-x 1 takuya staff 30 2019-04-02 16:52 regexp-tree -> ../regexp-tree/bin/regexp-tree lrwxr-xr-x 1 takuya staff 25 2019-04-02 16:52 regjsparser -> ../regjsparser/bin/parser lrwxr-xr-x 1 takuya staff 16 2019-04-02 16:52 rimraf -> ../rimraf/bin.js lrwxr-xr-x 1 takuya staff 15 2019-04-02 16:52 sass -> ../sass/sass.js lrwxr-xr-x 1 takuya staff 16 2019-04-02 16:52 sha.js -> ../sha.js/bin.js lrwxr-xr-x 1 takuya staff 16 2019-04-02 16:52 svgo -> ../svgo/bin/svgo lrwxr-xr-x 1 takuya staff 22 2019-04-02 16:52 terser -> ../terser/bin/uglifyjs lrwxr-xr-x 1 takuya staff 25 2019-04-02 16:52 uglifyjs -> ../uglify-js/bin/uglifyjs lrwxr-xr-x 1 takuya staff 25 2019-04-02 16:52 webpack -> ../webpack/bin/webpack.js lrwxr-xr-x 1 takuya staff 25 2019-04-02 16:52 webpack-cli -> ../webpack-cli/bin/cli.js lrwxr-xr-x 1 takuya staff 47 2019-04-02 16:52 webpack-dev-server -> ../webpack-dev-server/bin/webpack-dev-server.js lrwxr-xr-x 1 takuya staff 18 2019-04-02 16:52 which -> ../which/bin/which