Skip to content
Clean up your package.json with per-NODE_ENV npm scripts
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Correctly return child status code May 17, 2016
.nvmrc Initial commit Feb 26, 2016
.travis.yml Remove support for 0.12 Mar 15, 2016
LICENSE Initial commit Feb 26, 2016 Initial commit Feb 26, 2016
package.json 1.0.2 May 17, 2016


Clean up your package.json with per-NODE_ENV npm scripts.

travis build version downloads MIT License


  • Defaults NODE_ENV to development.
  • Customize process.env per-environment.
  • Clearer, concise scripts.
  • No more Bash-scripting in package.json.
  • Simplify your workflow:
    1. npm install
    2. npm start


  // Processes spawned by `per-env` inherit environment-specific
  // variables, if defined.
  "per-env": {
    "production": {
      "DOCKER_USER": "my",
      "DOCKER_REPO": "project"
  "scripts": {
    // If NODE_ENV is missing, defaults to "development".
    "build": "per-env",

    "build:development": "webpack -d --watch",
    "build:staging": "webpack -p",
    "build:production": "webpack -p",

    // Deployment won't work unless NODE_ENV=production is explicitly set.
    "deploy": "per-env",

    "predeploy:production": "docker build -t ${DOCKER_USER}/${DOCKER_PROJECT} .",
    "deploy:production": "docker push ${DOCKER_USER}/${DOCKER_PROJECT}",

    // "npm start" is _the_ command to start the server across all environments.
    "start": "per-env",

    "start:development": "npm run build:development",

    "prestart:production": "npm run build",
    "start:production": "start-cluster build/server/server.js",

    "prestart:staging": "npm run build",
    "start:staging": "start-cluster build/server/server.js",

    // Explicitly set NODE_ENV, which is helpful in CI.
    "test": "NODE_ENV=test per-env",

    "test:test": "mocha"


$ npm install --save per-env


MIT License 2016 © Eric Clemmons

You can’t perform that action at this time.