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