Alex Lomia
Alex Lomia

Reputation: 7225

How can I use only locally installed npm packages?

For example, to launch locally installed gulp, I have to run the following command from inside of my project:

node_modules/gulp/bin/gulp.js

To be able to launch npm packages only by their name, I want to include node_modules relatively to project's root dir. Is this possible?

P.S
I know how to install npm packages globally, but I'm trying to avoid doing that.

Upvotes: 1

Views: 62

Answers (1)

Mario Tacke
Mario Tacke

Reputation: 5488

I hope I understand you correctly: You are trying to execute programs like gulp from your local install.

You can set up a npm script like so in your package.json:

package.json

...
"scripts": {
  "build": "./node_modules/.bin/gulp"
}
...

Then, you can run gulp via npm run build from your command line. (Or optionally you can type ./node_modules/.bin/gulp)

Upvotes: 1

Related Questions