How do I use a local version of a module in node.js
. For example, in my app, I installed coffee-script:
npm install coffee-script
You don't have to manipulate $PATH
anymore!
From npm@5.2.0, npm ships with npx
package which lets you run commands from a local node_modules/.bin
or from a central cache.
Simply run:
$ npx [options] [@version] [command-arg]...
By default, npx
will check whether
exists in $PATH
, or in the local project binaries, and execute that.
Calling npx
when
isn't already in your $PATH
will automatically install a package with that name from the NPM registry for you, and invoke it. When it's done, the installed package won’t be anywhere in your globals, so you won’t have to worry about pollution in the long-term. You can prevent this behaviour by providing --no-install
option.
For npm < 5.2.0
, you can install npx
package manually by running the following command:
$ npm install -g npx