lerna: `NODE_ENV=production` is not honored when installing packages

Background: I want to use lerna bootstrap in a production setting, but there seems no way to add a --production flag to the underlying npm or yarn. Therefore I am trying the NODE_ENV env which are used by npm and yarn. See

However, lerna bootstrap does not seem to honor NODE_ENV either.

Expected Behavior

lerna bootstarp should honor NODE_ENV by exposing it to underlying npm install or yarn install command

Current Behavior

NODE_ENV is not honored.

Possible Solution

TBD

Steps to Reproduce (for bugs)

https://github.com/kevinpumpup/lerna-example

  • export NODE_ENV=production
  • yarn or npm install under packages/foo will not install dev dependencies
  • lerna bootstrap will install dev depedencies
lerna.json

{
  "lerna": "2.0.0-beta.38",
  "packages": [
    "packages/*"
  ],
  "version": "0.0.0"
}

Context

Want to use lerna bootstrap in a production context.

Your Environment

Executable Version
lerna --version 2.0.0-beta.38
npm --version 3.10.3
yarn --version 0.21.3
node --version v6.5.0
OS Version
macOS 10.11.6

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 13
  • Comments: 28 (10 by maintainers)

Commits related to this issue

Most upvoted comments

@Bamieh I think you still have a couple of things you can do to make this work for you. The first thing you might consider is hoisting all of your dev dependencies to the monorepo root – we symlink the binaries into the appropriate .bin directories, so you can keep using them as usual. This will mean that only production dependencies are ever installed in the modules that are uploaded to lambda. The other thing you might consider is adding an extra step to your deploy script that runs a lerna exec -- npm prune --production, which would have the same effect.

So, what is the expected way to bootstrap a monorepo for a production release which should not carry dev dependencies? Do I understand it correctly that currently there’s no way to do this?