I use a package called react-comments-section in my application which is compatible with node 16 only. My other packages are compatible with node 18. Locally, i use npm install --force to resolve all the conflicts and the application works just fine. But when I try to run on netlify, it uses npm install only and hence my project cannot initialize.
i tried writing build and prebuild script in package.json for npm install --force
I also tried making a netlify.toml file and specify npm install --force in the build configuration but it didn’t work. Do you have any solutions???
package.json
“scripts”: {
“prebuild”: “npm install --force”,
“build”: “npm run build”
}
netlify.toml
[build]
command = “npm run prebuild && npm run build”
error
11:22:42 AM: npm ERR! Could not resolve dependency:
11:22:42 AM: npm ERR! peer react@^16.0.0 from react-comments-section@2.0.10
11:22:42 AM: npm ERR! node_modules/react-comments-section
11:22:42 AM: npm ERR! react-comments-section@^2.0.10 from the root project
11:22:42 AM: npm ERR!
11:22:42 AM: npm ERR! Conflicting peer dependency: react@16.14.0
11:22:42 AM: npm ERR! node_modules/react
11:22:42 AM: npm ERR! peer react@^16.0.0 from react-comments-section@2.0.10
11:22:42 AM: npm ERR! node_modules/react-comments-section
11:22:42 AM: npm ERR! react-comments-section@^2.0.10 from the root project
11:22:42 AM: npm ERR!
11:22:42 AM: npm ERR! Fix the upstream dependency conflict, or retry
11:22:42 AM: npm ERR! this command with --force or --legacy-peer-deps