1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-29 23:24:55 +02:00
tldr/pages/common/npm.md

38 lines
1 KiB
Markdown
Raw Normal View History

2014-03-04 12:43:17 +11:00
# npm
> JavaScript and Node.js package manager.
> Manage Node.js projects and their module dependencies.
> More information: <https://www.npmjs.com>.
2014-03-04 12:43:17 +11:00
- Create a `package.json` file with default values (omit `--yes` to do it interactively):
2015-12-29 22:46:40 -06:00
`npm init {{-y|--yes}}`
2015-12-29 22:46:40 -06:00
- Download all the packages listed as dependencies in `package.json`:
2016-01-30 18:15:22 +02:00
`npm install`
- Download a specific version of a package and add it to the list of dependencies in `package.json`:
`npm install {{package_name}}@{{version}}`
- Download the latest version of a package and add it to the list of dev dependencies in `package.json`:
2014-03-04 12:43:17 +11:00
`npm install {{package_name}} {{-D|--save-dev}}`
2014-03-04 12:43:17 +11:00
- Download the latest version of a package and install it globally:
2024-09-17 09:59:41 +02:00
`npm install {{-g|--global}} {{package_name}}`
- Uninstall a package and remove it from the list of dependencies in `package.json`:
2014-03-04 12:43:17 +11:00
`npm uninstall {{package_name}}`
2014-03-04 12:43:17 +11:00
- List of locally installed dependencies:
2014-03-04 12:43:17 +11:00
`npm list`
2015-12-30 14:10:04 +01:00
- List top-level globally installed packages:
`npm list {{-g|--global}} --depth {{0}}`