What does the npm -i flag mean?

2019-03-14 09:39发布

问题:

What's does the "i" flag do in npm?

I saw it used like this:

npm i backbone.marionette

I looked in the npm documentation and searched for it on Google a fair amount. I'm not sure if it is a flag or command or maybe not an npm thing at all?

回答1:

the i flag is for install. From documentation:

npm install
npm install <pkg>
npm install <pkg>@<tag>
npm install <pkg>@<version>
npm install <pkg>@<version range>
npm install <folder>
npm install <tarball file>
npm install <tarball url>
npm install <git:// url>
npm install <github username>/<github project>

Can specify one or more: npm install ./foo.tgz bar@stable /some/folder
If no argument is supplied and ./npm-shrinkwrap.json is 
present, installs dependencies specified in the shrinkwrap.
Otherwise, installs dependencies from ./package.json.

Refer official document for more information here



回答2:

The i is npm-install alias which is mentioned in https://docs.npmjs.com/cli/install.

You can use it with all npm-install flags. For example below will install angular-js amd live server by using npm i

npm i angular2@2.0.0-alpha.45 --save --save-exact
npm i live-server --save-dev


标签: terminal npm