There are two ways of installing npm packages: globally or locally:
- If you plan to use the package from the command line, install it globally; for example, npm install prettier -g would install the prettier command so you can use it anywhere. (We'll see more of prettier in the Formatting your source code with Prettier section.) You may need to run the command as an administrator, or with sudo.
- Otherwise, if you just need the package for your project, install it locally.
Installing packages locally can also be done in more than one way:
- If you need the package for your own project, then you install it as a production package with npm install lodash --save
- Instead, if you need the package in order ...