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?
Install Package Globally NPM installs global packages into /<User>/local/lib/node_modules folder. Apply -g in the install command to install package globally.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With