2025-03-14 21:59:59 -06:00
|
|
|
# npm
|
|
|
|
|
|
|
|
|
|
> JavaScript and Node.js package manager.
|
|
|
|
|
> Manage Node.js projects and their module dependencies.
|
2025-09-14 18:48:49 -06:00
|
|
|
> More information: <https://docs.npmjs.com/cli/npm>.
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Create a `package.json` file with default values (omit `--yes` to do it interactively):
|
|
|
|
|
|
2025-03-19 19:23:44 -06:00
|
|
|
`npm init {{[-y|--yes]}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Download all the packages listed as dependencies in `package.json`:
|
|
|
|
|
|
2025-09-14 18:48:49 -06:00
|
|
|
`npm {{[i|install]}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Download a specific version of a package and add it to the list of dependencies in `package.json`:
|
|
|
|
|
|
2025-09-14 18:48:49 -06:00
|
|
|
`npm {{[i|install]}} {{package_name}}@{{version}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Download the latest version of a package and add it to the list of dev dependencies in `package.json`:
|
|
|
|
|
|
2025-09-14 18:48:49 -06:00
|
|
|
`npm {{[i|install]}} {{package_name}} {{[-D|--save-dev]}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Download the latest version of a package and install it globally:
|
|
|
|
|
|
2025-09-14 18:48:49 -06:00
|
|
|
`npm {{[i|install]}} {{[-g|--global]}} {{package_name}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Uninstall a package and remove it from the list of dependencies in `package.json`:
|
|
|
|
|
|
2025-09-14 18:48:49 -06:00
|
|
|
`npm {{[r|uninstall]}} {{package_name}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- List all locally installed dependencies:
|
|
|
|
|
|
2025-09-14 18:48:49 -06:00
|
|
|
`npm {{[ls|list]}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- List all top-level globally installed packages:
|
|
|
|
|
|
2025-09-14 18:48:49 -06:00
|
|
|
`npm {{[ls|list]}} {{[-g|--global]}} --depth {{0}}`
|