2014-03-04 01:43:17 +00:00
|
|
|
# npm
|
|
|
|
|
2016-01-30 13:04:30 +00:00
|
|
|
> JavaScript and Node.js package manager.
|
|
|
|
> Manage Node.js projects and their module dependencies.
|
2022-02-02 18:43:21 +00:00
|
|
|
> More information: <https://www.npmjs.com>.
|
2014-03-04 01:43:17 +00:00
|
|
|
|
2021-01-31 17:05:18 +00:00
|
|
|
- Interactively create a `package.json` file:
|
2015-12-30 04:46:40 +00:00
|
|
|
|
2019-03-07 20:07:40 +00:00
|
|
|
`npm init`
|
2015-12-30 04:46:40 +00:00
|
|
|
|
2019-03-07 20:07:40 +00:00
|
|
|
- Download all the packages listed as dependencies in package.json:
|
2016-01-30 16:15:22 +00:00
|
|
|
|
|
|
|
`npm install`
|
|
|
|
|
2021-01-31 17:05:18 +00:00
|
|
|
- Download a specific version of a package and add it to the list of dependencies in `package.json`:
|
2019-03-07 20:07:40 +00:00
|
|
|
|
2023-10-11 08:33:22 +01:00
|
|
|
`npm install {{package_name}}@{{version}}`
|
2019-03-07 20:07:40 +00:00
|
|
|
|
2023-10-11 08:32:21 +01:00
|
|
|
- Download the latest version of a package and add it to the list of dev dependencies in `package.json`:
|
2014-03-04 01:43:17 +00:00
|
|
|
|
2023-10-11 08:33:22 +01:00
|
|
|
`npm install {{package_name}} --save-dev`
|
2014-03-04 01:43:17 +00:00
|
|
|
|
2023-10-11 08:32:21 +01:00
|
|
|
- Download the latest version of a package and install it globally:
|
2016-05-04 09:46:42 +01:00
|
|
|
|
2023-10-11 08:33:22 +01:00
|
|
|
`npm install --global {{package_name}}`
|
2016-05-04 09:46:42 +01:00
|
|
|
|
2021-01-31 17:05:18 +00:00
|
|
|
- Uninstall a package and remove it from the list of dependencies in `package.json`:
|
2014-03-04 01:43:17 +00:00
|
|
|
|
2023-10-11 08:33:22 +01:00
|
|
|
`npm uninstall {{package_name}}`
|
2014-03-04 01:43:17 +00:00
|
|
|
|
2021-08-15 18:59:09 +01:00
|
|
|
- Print a tree of locally installed dependencies:
|
2014-03-04 01:43:17 +00:00
|
|
|
|
2016-01-30 13:04:30 +00:00
|
|
|
`npm list`
|
2015-12-30 13:10:04 +00:00
|
|
|
|
2023-10-11 08:33:22 +01:00
|
|
|
- List top-level globally installed packages:
|
2017-11-22 23:56:00 +00:00
|
|
|
|
2021-05-04 08:26:22 +01:00
|
|
|
`npm list --global --depth={{0}}`
|