[BUG] npm install --omit=dev --omit=peer is installing peer dependencies of dependencies
Nobody has claimed this yet.
- 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
Please see the following package.json. When installing using npm install --omit=dev --omit=peer, the dependency react-text-mask causes npm to install it's peer dependency for react@18.
{
"name": "sample",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
},
"author": "",
"license": "ISC",
"peerDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"dependencies": {
"react-text-mask": "^5.5.0",
"rxjs": "^7.8.0"
}
}
The pacakge.json for react-text-mask looks as follows:
{
"name": "react-text-mask",
"version": "5.5.0",
"description": "React input component that accepts mask pattern",
"main": "dist/reactTextMask.js",
"author": "M.K. Safi <msafi@msafi.com>",
"license": "Unlicense",
"bugs": {
"url": "https://github.com/text-mask/text-mask/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/text-mask/text-mask.git"
},
"homepage": "https://github.com/text-mask/text-mask/tree/master/react/#readme",
"peerDependencies": {
"react": "^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0"
},
"babel": {
"presets": [
"env",
"react",
"stage-0"
]
},
"keywords": [
"react",
"react-component",
"text mask",
"input mask",
"string mask",
"input formatting",
"text formatting",
"string formatting"
],
"dependencies": {
"prop-types": "^15.5.6"
}
}
It includes only a single peerDepencency for react.
Expected Behavior
Expected behavior is that peerDependencies of my component's dependencies are not installed.
Steps To Reproduce
With the package.json described in the current behavior section, run npm i --omit=dev --omit=peer.
Examine the node_modules folder and see that the dependency react has been installed. (It is a peerDependency of a dependency and should be omitted.)
Environment
- npm: 8.19.3
- Node.js: 16.19.0
- OS Name: Windows 10
- System Model Name:
- npm config:
; "user" config from C:\Users\admin\.npmrc
registry = "https://registry.npmjs.org/"
strict-ssl = false
; node bin location = C:\Program Files\nodejs\node.exe
; node version = v16.19.0
; npm local prefix = C:\Users\admin\workspace\test
; npm version = 8.19.3
; cwd = C:\Users\admin\workspace\test
; HOME = C:\Users\admin
; Run `npm config ls -l` to show all defaults.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the package.json shown in the issue and run npm i --omit=dev --omit=peer using the stated reproduction. Inspect node_modules and npm's dependency-resolution entry points to trace why react is installed through react-text-mask. Done means the command omits peer dependencies of dependencies while preserving the requested install behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs, react
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100