npm / npm/cli

[BUG] Dev dependency should not throw “unsupported platform” error when using --production flag on npm install

Open
#2,921 6 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Release 7.x
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Current Behavior:

If you have a module that is not supported on your platform set in the devDependencies object in your package file and you do a production install using the --production flag, the installation fails with an “Unsupported platform” (EBADPLATFORM) error. Since the module should not be installed/used during a production install, it should also not throw an error or otherwise affect the outcome of the installation.

Expected Behavior:

A module that’s declared in devDependencies should not affect the outcome of a production install.

Steps To Reproduce:
  1. Create a module, M, that specifies an OS different to the one you’re currently on in its npm package file. e.g., if you’re on a Mac, specify:
  "os": [
    "win32"
  ]
  1. Create an app, A, that includes module M in its devDependencies. e.g.,
  "devDependencies": {
    "M": "1.0.0"
}
  1. Do a production install on app A:
npm install --production

Note that the installation fails because module M is not supported on your system, even though you’re doing a production build and module M should not be installed or used.

Environment:
  • OS (noticed/reproduced on): macOS Big Sur
  • Node: 14.16.0
  • npm: 7.6.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the package setup described and npm install --production on an unsupported dev dependency. Trace npm's production dependency resolution and platform validation; done means the dev dependency no longer affects the production install outcome and the reproduction completes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.