Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore peer dependency check for single package in package.json

I try to exclude the package react-virtualized from the peer dependency checking of NPM 7. I know I could separately install that package with

npm install react-virtualized --legacy-peer-deps

...but my goal is to install all packages with npm install and this one shall not be checked for peer dependencies. Is that possible?

I would accept any answer that shows me how to manipulate the package.json so that a fresh npm install runs without peer dependency errors. I have the following package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-redux": "^7.2.4",
    "react-router": "^5.2.0",
    "react-router-dom": "^5.2.0",
    "react-beautiful-dnd": "^13.1.0",
    "react-device-detect": "^1.11.14",
    "react-markdown": "^7.0.0",
    "react-resize-detector": "^6.7.1",
    "react-virtualized": "^9.22.3"
  }  
}
like image 257
user3601578 Avatar asked Jan 23 '26 12:01

user3601578


1 Answers

With npm@>=8.3.0 use overrides in package.json:

"overrides": {
  "react-virtualized": {
    "react": "$react",
    "react-dom": "$react-dom"
  }
}

See https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides

like image 136
Vitaly Kuznetsov Avatar answered Jan 25 '26 09:01

Vitaly Kuznetsov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!