npm install packages in package.json code example
Example 1: install node_modules
npm install
Example 2: how to install any package in node.js
npm install packagename
npm install express
npm i express
npm install express -g
Example 3: install an npm package
npm install package-name
To save as a dependency:
npm install package-name --save
Example 4: install node modules from package.json
npm install (with no args, in package dir)
npm install [<@scope>/]<name>
npm install [<@scope>/]<name>@<tag>
npm install [<@scope>/]<name>@<version>
npm install [<@scope>/]<name>@<version range>
npm install <git-host>:<git-user>/<repo-name>
npm install <git repo url>
npm install <tarball file>
npm install <tarball url>
npm install <folder>
aliases: npm i, npm add
common options: [-P|--save-prod|-D|--save-dev|-O|--save-optional] [-E|--save-exact] [-B|--save-bundle] [--no-save] [--dry-run]
Example 5: how to install npm packages
npm i <package>