[BUG] Dev dependency should not throw “unsupported platform” error when using --production flag on npm install #2921
Open
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:
- 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"
]
- Create an app, A, that includes module M in its
devDependencies
. e.g.,
"devDependencies": {
"M": "1.0.0"
}
- 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