Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's an npm command to install devDependencies globally?

I'd prefer to type a short command, like npm install -g, to setup a project's global dependencies, such as node-sass and jshint, than manually typing out npm install -g every single package. Is there an npm-idiomatic way to do this?

like image 326
apennebaker Avatar asked Aug 06 '13 21:08

apennebaker


People also ask

How install npm install globally?

Install Package Globally NPM installs global packages into /<User>/local/lib/node_modules folder. Apply -g in the install command to install package globally.

Does npm install install devDependencies?

When you (or another user) run npm install , npm will download dependencies and devDependencies that are listed in package. json that meet the semantic version requirements listed for each. To see which versions of a package will be installed, use the semver calculator.

Does npm install packages globally?

Installing a package globally allows you to use the code in the package as a set of tools on your local computer. If you get an EACCES permissions error, you may need to reinstall npm with a version manager or manually change npm's default directory.


1 Answers

You are using npm install -g <pkg> wrong here. -g indicates, that it's no project dependencies, than rather you global (PC wide).

Those plugins are no devDependencies, but CLI runners. What you want is npm install --save-dev every single package upon initialisation. When you need to install those dependencies again you'd just run npm install and include something like ./node_modules/.bin/jshint to your package.json scripts in order not to depend on the CLIs.

like image 80
eljefedelrodeodeljefe Avatar answered Oct 07 '22 06:10

eljefedelrodeodeljefe