简体   繁体   中英

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?

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

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 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM