简体   繁体   中英

How to resolve peer dependency conflict

Thanks for reading.

After testing some changes in my local dev environment and having no issues, I promoted the changes to my test environment hosted on AWS Amplify, and the build was failing with the following error:

2022-11-28T19:47:50.604Z [WARNING]: ERR! ERESOLVE could not resolve
                                    npm ERR!
                                    npm
2022-11-28T19:47:50.605Z [WARNING]: ERR! While resolving: styles@0.2.1
                                    npm ERR! Found: assemble@0.24.3
                                    npm ERR! node_modules/assemble
                                    npm ERR!
2022-11-28T19:47:50.605Z [WARNING]: assemble@"^0.24.3" from the root project
                                    npm ERR!
                                    npm ERR! Could not resolve dependency:
                                    npm ERR! peer assemble@"~0.3.11" from styles@0.2.1
                                    npm ERR! node_modules/styles
                                    npm ERR!   styles@"^0.2.1" from the root project
                                    npm ERR!
                                    npm ERR! Conflicting peer dependency: assemble@0.3.83
                                    npm ERR! node_modules/assemble
                                    npm ERR!   peer assemble@"~0.3.11" from styles@0.2.1
                                    npm ERR!   node_modules/styles
                                    npm ERR!     styles@"^0.2.1" from the root project
                                    npm ERR!
                                    npm ERR!
2022-11-28T19:47:50.605Z [WARNING]: Fix the upstream dependency conflict, or retry
                                    npm ERR! this command with --force, or --legacy-peer-deps
                                    npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
                                    npm ERR!
                                    npm ERR! See /root/.npm/eresolve-report.txt for a full report.

Here are the two dependencies mentioned in the above error, in the package.json file:

"assemble": "^0.24.3",
"styles": "^0.2.1"

Here are the two dependencies mentioned above, in the package-lock file:

"node_modules/styles": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/styles/-/styles-0.2.1.tgz",
"integrity": "sha1-hJJ7pEf6pvJJ7NIK3wu4X606UUE=",
"dependencies": {
"less": "\~1.4.0"
},
"engines": {
"node": "\>= 0.8.0"
},
"peerDependencies": {
"assemble": "\~0.3.11",
"grunt": "\~0.4.0"
}
},

"node_modules/assemble": {
"version": "0.24.3",
"resolved": "https://registry.npmjs.org/assemble/-/assemble-0.24.3.tgz",
"integrity": "sha1-lSp3S3iAl6TW9Iw6QrpW9ouNZS8=",
"dependencies": {
"assemble-core": "^0.31.0",
"assemble-loader": "^1.0.5",
"base-argv": "^0.5.0",
"base-cli-process": "^0.1.19",
"base-config": "^0.5.2",
"base-questions": "^0.9.1",
"base-runtimes": "^0.2.0",
"cross-spawn": "^5.1.0",
"engine-handlebars": "^0.8.2",
"expand-front-matter": "^1.0.0",
"export-files": "^2.1.1",
"global-modules": "^0.2.3",
"is-valid-app": "^0.3.0",
"lazy-cache": "^2.0.2",
"log-utils": "^0.2.1",
"minimist": "^1.2.0",
"parser-front-matter": "^1.6.3",
"resolve-dir": "^1.0.0"
},
"bin": {
"assemble": "bin/cli.js"
},
"engines": {
"node": "\>=4.0"
}
},

I tried running the build with --force, and --legacy-peer-deps, but neither of the two dependencies mentioned above (assemble, and styles) are affected by either operation, and I still have the same issue.

I've tried installing the version of assemble to version 0.3.11 (as listed as the peerDependecy of styles), and again the build in my local environment works, but after promoting to my test environment on AWS Amplify, the build fails with the following errors:

2022-11-28T19:38:40.756Z [WARNING]: npm ERR!
2022-11-28T19:38:40.756Z [WARNING]: code EUSAGE
2022-11-28T19:38:40.760Z [WARNING]: npm
2022-11-28T19:38:40.760Z [WARNING]: ERR!
                                    npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
                                    npm ERR!
                                    npm ERR! Missing: immutable@4.1.0 from lock file
                                    npm ERR! Missing: seamless-immutable@7.1.4 from lock file
                                    npm ERR! Missing: typescript@4.9.3 from lock file

I also uninstalled assemble and styles, but ran into the same error when trying to build the test environment.

Additionally, I went and looked at my commit history, and the package.json and package-lock.json files haven't been changed in months, and I've had many successful builds since they were last modified, which adds to my confusion of where this problem came from.

Further info:

Local Dev environment is using node v16.13.1 and npm v8.1.2, and Amplify build image (default image) just specifies in the build logs that its using Node version 16

Uninstalling both dependencies and then running npm update resolved my issues

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM