[Node.js] npm package executable files exist as symbolic links in node_modules/.bin

Tadashi Shigeoka ·  Sat, April 23, 2016

In Node.js, executable files from packages installed via npm install are automatically created as symbolic links in the node_modules/.bin directory.

npm | エヌピーエム

(Example) Inside a certain node_modules/.bin directory

$ ls -l ./node_modules/.bin
lrwxr-xr-x  1 codenote  staff  22 Apr 21 18:11 express -> ../express/bin/express
lrwxr-xr-x  1 codenote  staff  22 Apr 21 18:11 grunt -> ../grunt-cli/bin/grunt
lrwxr-xr-x  1 codenote  staff  16 Apr 21 18:11 jade -> ../jade/bin/jade
lrwxr-xr-x  1 codenote  staff  21 Apr 21 18:12 npm -> ../npm/bin/npm-cli.js

I was surprised that I didn’t know this even after more than 4 years of Node.js development.

By the way, symbolic links are created in /path/your_project/node_modules/.bin only when the module has commands prepared.

That’s all from the Gemba.