From aaa6cb7212fe9c571a50fc5a0f9eb30a0049baa4 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Fri, 27 Oct 2017 12:29:55 +0800 Subject: [PATCH] npm: update --- npm.md | 89 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 25 deletions(-) diff --git a/npm.md b/npm.md index b6882154d..5055e2475 100644 --- a/npm.md +++ b/npm.md @@ -1,39 +1,78 @@ --- title: npm category: JavaScript +layout: 2017/sheet +weight: -1 +updated: 2017-10-27 --- - npm install - npm shrinkwrap +### Package management -### 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 - npm owner add USERNAME PACKAGENAME +`--save` is the default as of npm@5. Previously, using `npm install` without `--save` doesn't update package.json. - # list packages - npm ls +### Install names - # Remove duplicates down the dep tree - npm dedupe +| Command | Description | +| --- | --- | +| `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 - npm deprecate PACKAGE@"< 0.2.0" "critical bug fixed in v0.2.0" +### Updating - # Add a package as a git submodule - npm submodule PACKAGE +| Command | Description | +| --- | --- | +| `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 - npm outdated [PACKAGE] +### Misc features -npm owner add josefrancisco.verdu@gmail.com docpress -npm owner add josefrancisco.verdu@gmail.com docpress-core -npm owner add josefrancisco.verdu@gmail.com docpress-base -npm owner add josefrancisco.verdu@gmail.com docpress-search -npm owner add ilya@burstcreations.com docpress -npm owner add ilya@burstcreations.com docpress-core -npm owner add ilya@burstcreations.com docpress-base -npm owner add ilya@burstcreations.com docpress-search +```bash +# Add someone as an owner +npm owner add USERNAME PACKAGENAME +``` + +```bash +# list packages +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] +```