npm / npm/cli

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

Open
#8,284 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

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.

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 command using npm 11.3.0, the sass-1.87.0.tgz archive, --global, and --omit=optional. Trace how npm handles omit settings for global installs from tar.gz archives; done when the optional dependency is absent from the installed package.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.