npm install --dev=prod keep downloading devDependencies on Windows, linux works

What I Wanted to Do

I want to install a package with --only=prod and don´t want any devDependencies to be installed nor child devDependencies.

What Happened Instead

a child dependencie tries to install devDependencies and fails.
as shwon in the log npm tries to install devDependencies
error prepareGitDep 2> npm WARN install Usage of the `--dev` option is deprecated. Use `--only=dev` instead.

Reproduction Steps

using Windows just create a new folder and on cmd type:
npm install ngx-mqtt --only=prod
in the new folder.

using Linux do the same and you get only the prodDependencies

Details

I also tried --production and my ENV_NODE is set to production

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'ngx-mqtt',
1 verbose cli   '--only=prod',
1 verbose cli   '--loglevel',
1 verbose cli   'verbose' ]
2 info using npm@6.9.0
3 info using node@v11.11.0
4 verbose npm-session ed147bd35e81fd50
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 304 https://registry.npmjs.org/ngx-mqtt 360ms (from cache)
8 silly pacote tag manifest for ngx-mqtt@latest fetched in 391ms
9 timing stage:loadCurrentTree Completed in 422ms
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 timing stage:loadIdealTree:cloneCurrentTree Completed in 1ms
13 silly install loadShrinkwrap
14 timing stage:loadIdealTree:loadShrinkwrap Completed in 3ms
15 silly install loadAllDepsIntoIdealTree
16 silly resolveWithNewModule ngx-mqtt@6.8.5 checking installable status
17 http fetch GET 304 https://registry.npmjs.org/@types%2fnode 120ms (from cache)
18 silly pacote version manifest for @types/node@10.3.2 fetched in 135ms
19 silly resolveWithNewModule @types/node@10.3.2 checking installable status
20 http fetch GET 304 https://registry.npmjs.org/ssri 183ms (from cache)
21 silly pacote range manifest for ssri@>=6.0.0 fetched in 190ms
22 silly resolveWithNewModule ssri@6.0.1 checking installable status
23 http fetch GET 304 https://registry.npmjs.org/ecstatic 199ms (from cache)
24 silly pacote range manifest for ecstatic@>=3.2.0 fetched in 208ms
25 silly resolveWithNewModule ecstatic@3.3.1 checking installable status
26 verbose prepareGitDep mqtt@github:mqttjs/MQTT.js#62641d6ec22e4e51b1cacd3f692965d44a09d03e: installing devDeps and running prepare script.
27 error prepareGitDep 1>
27 error prepareGitDep > pre-commit@1.2.2 install C:\Users\REPE400\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-f3b6beb9\node_modules\pre-commit
27 error prepareGitDep > node install.js
27 error prepareGitDep
27 error prepareGitDep
27 error prepareGitDep > spawn-sync@1.0.15 postinstall C:\Users\REPE400\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-f3b6beb9\node_modules\spawn-sync
27 error prepareGitDep > node postinstall
27 error prepareGitDep
27 error prepareGitDep
27 error prepareGitDep > ngrok@2.1.8 postinstall C:\Users\REPE400\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-f3b6beb9\node_modules\ngrok
27 error prepareGitDep > node ./postinstall.js
27 error prepareGitDep
27 error prepareGitDep ngrok - downloading binary https://bin.equinox.io/a/chRZWPptE7w/ngrok-2.1.1-windows-amd64.zip ...
27 error prepareGitDep ngrok - binary downloaded...
28 error prepareGitDep 2> npm WARN install Usage of the `--dev` option is deprecated. Use `--only=dev` instead.
28 error prepareGitDep npm WARN deprecated istanbul@0.4.5: This module is no longer maintained, try this instead:
28 error prepareGitDep npm WARN deprecated   npm i nyc
28 error prepareGitDep npm WARN deprecated Visit https://istanbul.js.org/integrations for other alternatives.
28 error prepareGitDep npm WARN deprecated formatio@1.1.1: This package is unmaintained. Use @sinonjs/formatio instead
28 error prepareGitDep npm WARN deprecated samsam@1.1.2: This package has been deprecated in favour of @sinonjs/samsam
28 error prepareGitDep npm WARN deprecated samsam@1.1.3: This package has been deprecated in favour of @sinonjs/samsam
28 error prepareGitDep npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
28 error prepareGitDep npm WARN deprecated tar.gz@1.0.7: ⚠️  WARNING ⚠️ tar.gz module has been deprecated and your application is vulnerable. Please use tar module instead: https://npmjs.com/tar
28 error prepareGitDep npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
28 error prepareGitDep npm WARN deprecated istanbul@0.2.16: This module is no longer maintained, try this instead:
28 error prepareGitDep npm WARN deprecated   npm i nyc
28 error prepareGitDep npm WARN deprecated Visit https://istanbul.js.org/integrations for other alternatives.
28 error prepareGitDep npm WARN deprecated wrench@1.5.9: wrench.js is deprecated! You should check out fs-extra (https://github.com/jprichardson/node-fs-extra) for any operations you were using wrench for. Thanks for all the usage over the years.
28 error prepareGitDep npm WARN deprecated connect@2.12.0: connect 2.x series is deprecated
28 error prepareGitDep npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
28 error prepareGitDep npm WARN deprecated minimatch@0.4.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
28 error prepareGitDep npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
28 error prepareGitDep npm WARN deprecated graceful-fs@3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
28 error prepareGitDep npm WARN deprecated minimatch@1.0.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
28 error prepareGitDep npm WARN deprecated hoek@0.9.1: The major version is no longer supported. Please update to 4.x or newer
28 error prepareGitDep npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
28 error prepareGitDep ngrok - error unpacking binary Error: You cannot extract a file outside of the target path
28 error prepareGitDep     at C:\Users\REPE400\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-f3b6beb9\node_modules\decompress-zip\lib\decompress-zip.js:95:21
28 error prepareGitDep     at Array.map (<anonymous>)
28 error prepareGitDep     at C:\Users\REPE400\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-f3b6beb9\node_modules\decompress-zip\lib\decompress-zip.js:91:25
28 error prepareGitDep     at _fulfilled (C:\Users\REPE400\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-f3b6beb9\node_modules\decompress-zip\node_modules\q\q.js:854:54)
28 error prepareGitDep     at C:\Users\REPE400\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-f3b6beb9\node_modules\decompress-zip\node_modules\q\q.js:883:30
28 error prepareGitDep     at Promise.promise.promiseDispatch (C:\Users\REPE400\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-f3b6beb9\node_modules\decompress-zip\node_modules\q\q.js:816:13)
28 error prepareGitDep     at C:\Users\REPE400\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-f3b6beb9\node_modules\decompress-zip\node_modules\q\q.js:624:44
28 error prepareGitDep     at runSingle (C:\Users\REPE400\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-f3b6beb9\node_modules\decompress-zip\node_modules\q\q.js:137:13)
28 error prepareGitDep     at flush (C:\Users\REPE400\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-f3b6beb9\node_modules\decompress-zip\node_modules\q\q.js:125:13)
28 error prepareGitDep     at processTicksAndRejections (internal/process/next_tick.js:74:9)
28 error prepareGitDep npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules\fsevents):
28 error prepareGitDep npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
28 error prepareGitDep
28 error prepareGitDep npm ERR! code ELIFECYCLE
28 error prepareGitDep npm ERR! errno 1
28 error prepareGitDep npm ERR! ngrok@2.1.8 postinstall: `node ./postinstall.js`
28 error prepareGitDep npm ERR! Exit status 1
28 error prepareGitDep npm ERR!
28 error prepareGitDep npm ERR! Failed at the ngrok@2.1.8 postinstall script.
28 error prepareGitDep npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
28 error prepareGitDep
28 error prepareGitDep npm ERR! A complete log of this run can be found in:
28 error prepareGitDep npm ERR!     C:\Users\REPE400\AppData\Roaming\npm-cache\_logs\2019-03-14T09_02_02_016Z-debug.log
29 silly fetchPackageMetaData error for mqtt@github:mqttjs/MQTT.js#62641d6ec22e4e51b1cacd3f692965d44a09d03e premature close
30 timing stage:rollbackFailedOptional Completed in 1ms
31 timing stage:runTopLevelLifecycles Completed in 57092ms
32 silly saveTree npmtest
32 silly saveTree `-- ngx-mqtt@6.8.5
32 silly saveTree   +-- @types/node@10.3.2
32 silly saveTree   +-- ecstatic@3.3.1
32 silly saveTree   `-- ssri@6.0.1
33 verbose stack Error: premature close
33 verbose stack     at PassThrough.onclose (C:\Users\xxx\AppData\Roaming\npm\node_modules\npm\node_modules\end-of-stream\index.js:47:67)
33 verbose stack     at PassThrough.emit (events.js:202:15)
33 verbose stack     at emitCloseNT (internal/streams/destroy.js:59:8)
33 verbose stack     at processTicksAndRejections (internal/process/next_tick.js:76:17)
34 verbose cwd C:\xampp\htdocs\tests\npmtest
35 verbose Windows_NT 10.0.15063
36 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "ngx-mqtt" "--only=prod" "--loglevel" "verbose"
37 verbose node v11.11.0
38 verbose npm  v6.9.0
39 error premature close
40 verbose exit [ 1, true ]

Platform Info

$ npm --versions
v11.11.0
$ node -p process.platform
6.9.0
also tested 6.7.0 and 6.8.0

Is mqtt a production dependency from a git source? If so, git deps require an extra build step (prepareGitDep) to make sure generated files that aren’t included in the git repository are actually available. For that, it will have to install dev deps.

“mqtt”: “github:mqttjs/MQTT.js#62641d6ec22e4e51b1cacd3f692965d44a09d03e” is part of the production dependencies for ngx-mqtt.
what i don´t understand is the difference in Windows and Linux behavior.
Linux did not install the devDependencies using the same commands

The same build step is being run on Linux, but it’s only causing an error on Windows. More info here:

Also, this doesn’t seem like an issue with npm itself, but rather with ngrok (and more specifically zuul-ngrok not publishing the updated version to npm), so I moved it to #support.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.