Skip to content

Instantly share code, notes, and snippets.

@alundiak
Last active December 19, 2021 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alundiak/1fab5f2197d5ce1f75a58bb394062916 to your computer and use it in GitHub Desktop.
Save alundiak/1fab5f2197d5ce1f75a58bb394062916 to your computer and use it in GitHub Desktop.
Variants of npm commands depends on NODE_ENV value
npm install
npm install --omit=dev
npm install --include=dev
npm ci
npm ci --omit=dev
npm ci --include=dev
NODE_ENV=development npm install
NODE_ENV=development npm install --omit=dev
NODE_ENV=development npm install --include=dev
NODE_ENV=development npm ci
NODE_ENV=development npm ci --omit=dev
NODE_ENV=development npm ci --include=dev
NODE_ENV=production npm install
NODE_ENV=production npm install --omit=dev
NODE_ENV=production npm install --include=dev
NODE_ENV=production npm ci
NODE_ENV=production npm ci --omit=dev
NODE_ENV=production npm ci --include=dev
npm ci -- NODE_ENV=production
npm ci -- "NODE_ENV=production"
export NODE_ENV=production && npm install
export NODE_ENV=production && npm install --omit=dev
export NODE_ENV=production && npm install --include=dev
export NODE_ENV=production && npm ci
export NODE_ENV=production && npm ci --omit=dev
export NODE_ENV=production && npm ci --include=dev

test.sh:

#!/bin/bash
export NODE_ENV="production"
./test.sh
source ./test.sh
source ./test.sh && npm ci

package.json:

"scripts": {
  "eslint": "eslint --fix ./js/*.js",
  "eslint-ci": "eslint ./js/*.js",
  "my-install-1": "npm ci -- NODE_ENV=production",
  "my-install-2": "NODE_ENV=production npm ci",
  "my-install-3": "export NODE_ENV=production && npm ci",
  "my-install-4": "./test.sh && npm ci",
  "my-install-5": "source ./test.sh && npm ci",
  "my-eslint-2": "cross-env NODE_ENV=production npm run eslint",
  "my-eslint-3": "env-cmd npm run eslint",
  "my-over-complicated-install": "npx cross-env NODE_ENV=production npm ci --include=dev"
}
npm install cross-env
npm install cross-env --global
npm install env-cmd
npm install env-cmd --global
npm install npx --global
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment