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
- https://yarnpkg.com/lang/en/docs/cli/install/#toc-yarn-install-production
- https://docs.npmjs.com/cli/install
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
ornpm install
underpackages/foo
will not install dev dependencieslerna 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
- pass process.env to all spawned children Fixes: #721 — committed to arcticShadow/lerna by deleted user 7 years ago
@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?