Last Updated: January 28, 2019
·
1.657K
· frostwind

Run locally installed node packages binaries

I don't really like installing node packages globally using the -g flag.

So this is what i do to install packages that have to be run with the command line.

Let's take gulp for example :

npm install gulp

In your package.json add the following under "scripts":

"scripts": {
  "build": "gulp your_gulp_task"
}

Before this change, the only option was to either install gulp globally or run it using this command from your project directory:

./node_modules/.bin/gulp your_gulp_task

Now all you have to do is :

npm run build

It's a matter of preference but i like the second command more, so, if you're like me, i hope this has helped you.

Another thing to note is that you can use "start" and "test" as script names in package.json.
That way you can omit the run and just type npm start or npm test

Have fun !