cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] npm install: --omit flag does not work in combination with --global and tar.gz package archive

Open knuxify opened this issue 7 months ago • 0 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

This issue exists in the latest npm version

  • [x] I am using the latest npm

Current Behavior

I'm trying to build the sass package with the following command:

npm install \                                                                                                             
        --global \                                                                                                            
        --prefix "/usr" \                                                                                              
        --omit=optional \                                                                                                     
        "sass-1.87.0.tgz"

(URL to the tar.gz file: https://registry.npmjs.org/sass/-/sass-1.87.0.tgz)

Despite this, the optional dependency, @parcel/watcher, still ends up in node_modules:

$ ls /usr/lib/node_modules/sass/node_modules/
total 60K
4.0K @parcel   4.0K detect-libc  4.0K is-extglob  4.0K micromatch      4.0K readdirp
4.0K braces    4.0K fill-range   4.0K is-glob     4.0K node-addon-api  4.0K source-map-js
4.0K chokidar  4.0K immutable    4.0K is-number   4.0K picomatch       4.0K to-regex-range
$ ls /usr/lib/node_modules/sass/node_modules/@parcel/
total 8.0K
4.0K watcher  4.0K watcher-linux-x64-musl

Expected Behavior

The optional dependency is not there when passing the --omit=optional flag.

Steps To Reproduce

Try to install sass from the tar.gz file as described above.

Environment

  • npm: 11.3.0
  • Node.js: v23.11.0
  • OS Name: Alpine Linux edge
  • npm config:
; "builtin" config from /usr/lib/node_modules/npm/npmrc

globalignorefile = "/etc/npmignore"
prefix = "/usr/local"
python = "/usr/bin/python3"

; node bin location = /usr/bin/node
; node version = v23.11.0
; npm local prefix = (removed)
; npm version = 11.3.0
; cwd = (removed)
; HOME = /home/knuxify
; Run `npm config ls -l` to show all defaults.

knuxify avatar May 10 '25 07:05 knuxify