1

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.

Alex Lomia
  • 6,705
  • 12
  • 53
  • 87
  • have you tried going into your project directory and install it? – nCore Apr 02 '16 at 08:23
  • I have run npm install from my project directory. All packages have been installed successfully. As I already mentioned in the question, running `node_modules/gulp/bin/gulp.js` does the job. However, running only `gulp` results in `bash: gulp: command not found` error. – Alex Lomia Apr 02 '16 at 08:26
  • 1
    [How to use package installed locally in node_modules?](http://stackoverflow.com/questions/9679932/how-to-use-package-installed-locally-in-node-modules) – Francesco Pezzella Apr 02 '16 at 08:36

1 Answers1

1

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)

Mario Tacke
  • 5,378
  • 3
  • 30
  • 49