Skip to content

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

Open
@knuxify

Description

@knuxify

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingPriority 2secondary priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions