Skip to content

fix: migrate from NPM_CONFIG_PRODUCTION to NPM_CONFIG_OMIT - #369

Open
iloveitaly wants to merge 5 commits into
railwayapp:mainfrom
iloveitaly:claude/npm-omit-migration-01TxuroycdoHafSVazyMibFN
Open

fix: migrate from NPM_CONFIG_PRODUCTION to NPM_CONFIG_OMIT#369
iloveitaly wants to merge 5 commits into
railwayapp:mainfrom
iloveitaly:claude/npm-omit-migration-01TxuroycdoHafSVazyMibFN

Conversation

@iloveitaly

@iloveitaly iloveitaly commented Nov 18, 2025

Copy link
Copy Markdown
Collaborator

Replace the deprecated NPM_CONFIG_PRODUCTION environment variable with
explicit npm dependency-group flags:

  • npm install and npm ci use --include=dev so build dependencies remain
    available while NODE_ENV=production.
  • npm prune uses --omit=dev, matching the previous production-pruning
    behavior while retaining optional dependencies.
  • The deprecated variable is no longer included in the runtime image.

Breaking Changes

  • Runtime npm commands now follow NODE_ENV=production. An npm install run
    inside a deployed image will omit dev dependencies instead of inheriting
    NPM_CONFIG_PRODUCTION=false. Applications or scripts that inspect that
    variable will no longer see it.
  • The generated npm install command explicitly uses --include=dev. npm gives
    include precedence over omit, so an existing .npmrc containing
    omit=dev will no longer suppress dev dependencies during Railpack's install
    step. Users who intentionally need that behavior can replace the install
    command, for example with
    RAILPACK_INSTALL_CMD="npm ci --omit=dev".
  • --include=dev is supported by npm 7 and newer. Projects pinned to npm 6 or
    earlier may not install dev dependencies correctly while
    NODE_ENV=production and should override the install command or upgrade npm.
  • Install lifecycle scripts and custom prune commands that explicitly depend
    on NPM_CONFIG_PRODUCTION may behave differently. NODE_ENV remains set to
    production.
  • Generated build plans now contain npm ci --include=dev or
    npm install --include=dev. Tooling that matches exact command strings may
    require an update, and existing build caches will be invalidated once.

Optional dependencies continue to be installed, matching the behavior before
this migration.

@iloveitaly
iloveitaly force-pushed the claude/npm-omit-migration-01TxuroycdoHafSVazyMibFN branch from 072d9af to c66c64b Compare November 21, 2025 14:25
@iloveitaly iloveitaly changed the title feat: migrate from NPM_CONFIG_PRODUCTION to NPM_CONFIG_OMIT fix: migrate from NPM_CONFIG_PRODUCTION to NPM_CONFIG_OMIT Nov 22, 2025
@iloveitaly
iloveitaly force-pushed the claude/npm-omit-migration-01TxuroycdoHafSVazyMibFN branch from 8b363db to 321ee98 Compare March 13, 2026 16:44
@iloveitaly
iloveitaly marked this pull request as ready for review March 13, 2026 16:48
@iloveitaly
iloveitaly force-pushed the claude/npm-omit-migration-01TxuroycdoHafSVazyMibFN branch from 321ee98 to c9976a3 Compare July 23, 2026 19:27
claude and others added 5 commits July 23, 2026 14:42
Replace the deprecated NPM_CONFIG_PRODUCTION environment variable with
NPM_CONFIG_OMIT=dev,optional for exact parity with previous behavior.

Changes:
- Remove --omit=dev flag from npm prune command
- Set NPM_CONFIG_OMIT=dev,optional in prune step instead of NPM_CONFIG_PRODUCTION=true
- This approach uses environment variables as recommended

The new approach:
- Omits devDependencies (via "dev")
- Omits optionalDependencies (via "optional")
- Maintains NODE_ENV=production for lifecycle scripts

This provides exact behavioral parity with the old NPM_CONFIG_PRODUCTION=true
approach while using the modern npm configuration method.
- Replace global `NPM_CONFIG_PRODUCTION=false` and `NPM_CONFIG_OMIT` environment variables with explicit `--include=dev` during installation and `--omit=dev` during pruning.
- Prevent unintended global npm configuration side effects across build commands.

Generated-by: aiautocommit
@iloveitaly
iloveitaly force-pushed the claude/npm-omit-migration-01TxuroycdoHafSVazyMibFN branch from c9976a3 to 26baef5 Compare August 4, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants