How do you install a package?
A package is installed with the npm install command (or the shorthand npm i).
Installing dependencies in a project
- A regular dependency (goes into
dependencies):
bash
npm install <package-name>- A development-only dependency (in
devDependencies):
bash
npm install <package-name> --save-devInstalling globally (to use as a CLI)
bash
npm install -g <package-name>Summary
To install a package, you use the npm install command with the package name. Depending on the flag, the package ends up in regular dependencies, in dev dependencies, or gets installed globally.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.