npm: update

This commit is contained in:
Rico Sta. Cruz 2017-10-27 12:29:55 +08:00
parent 14eeab6568
commit aaa6cb7212
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
1 changed files with 64 additions and 25 deletions

89
npm.md
View File

@ -1,39 +1,78 @@
--- ---
title: npm title: npm
category: JavaScript category: JavaScript
layout: 2017/sheet
weight: -1
updated: 2017-10-27
--- ---
npm install ### Package management
npm shrinkwrap
### Adding owners | Command | Description |
| --- | --- |
| `npm i` | Alias for `npm install` |
| `npm install` | Install everything in package.json |
| --- | --- |
| `npm install lodash` | Install a package |
| `npm install --save-dev lodash` | Install as devDependency |
| `npm install --save-exact lodash` | Install with exact |
# Add someone as an owner `--save` is the default as of npm@5. Previously, using `npm install` without `--save` doesn't update package.json.
npm owner add USERNAME PACKAGENAME
# list packages ### Install names
npm ls
# Remove duplicates down the dep tree | Command | Description |
npm dedupe | --- | --- |
| `npm i sax` | NPM package |
| `npm i sax@latest` | Specify tag `latest` |
| `npm i sax@3.0.0` | Specify version `3.0.0` |
| `npm i sax@">=1 <2.0"` | Specify version range |
| --- | --- |
| `npm i @org/sax` | Scoped NPM package |
| --- | --- |
| `npm i user/repo` | GitHub |
| `npm i user/repo#master` | GitHub |
| `npm i github:user/repo` | GitHub |
| `npm i gitlab:user/repo` | GitLab |
| --- | --- |
| `npm i /path/to/repo` | Absolute path |
| `npm i ./archive.tgz` | Tarball |
| `npm i https://site.com/archive.tgz` | Tarball via HTTP |
# Adds warning to those that install a package of old versions ### Updating
npm deprecate PACKAGE@"< 0.2.0" "critical bug fixed in v0.2.0"
# Add a package as a git submodule | Command | Description |
npm submodule PACKAGE | --- | --- |
| `npm update` | Update production packages |
| `npm update --dev` | Update dev packages |
| `npm update -g` | Update global packages |
| --- | --- |
| `npm update lodash` | Update a package |
# update all packages, or selected packages
npm update [-g] PACKAGE
# Check for outdated packages ### Misc features
npm outdated [PACKAGE]
npm owner add josefrancisco.verdu@gmail.com docpress ```bash
npm owner add josefrancisco.verdu@gmail.com docpress-core # Add someone as an owner
npm owner add josefrancisco.verdu@gmail.com docpress-base npm owner add USERNAME PACKAGENAME
npm owner add josefrancisco.verdu@gmail.com docpress-search ```
npm owner add ilya@burstcreations.com docpress
npm owner add ilya@burstcreations.com docpress-core ```bash
npm owner add ilya@burstcreations.com docpress-base # list packages
npm owner add ilya@burstcreations.com docpress-search npm ls
```
```bash
# Adds warning to those that install a package of old versions
npm deprecate PACKAGE@"< 0.2.0" "critical bug fixed in v0.2.0"
```
```bash
# update all packages, or selected packages
npm update [-g] PACKAGE
```
```bash
# Check for outdated packages
npm outdated [PACKAGE]
```