冲突的对等依赖问题“[email protected] 和 [email protected]”

问题描述 投票:0回答:2

您好,我正在尝试使用 npm install @splidejs/splide 安装 splide.js 但出现此错误:

npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: [email protected] npm ERR! Found: [email protected] npm ERR! node_modules/browser-sync npm ERR!   dev browser-sync@"^3.0.2" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer browser-sync@"^2" from [email protected] npm ERR! node_modules/browser-sync-webpack-plugin npm ERR!   dev browser-sync-webpack-plugin@"^2.3.0" from the root project npm ERR! npm ERR! Conflicting peer dependency: [email protected] npm ERR! node_modules/browser-sync npm ERR!   peer browser-sync@"^2" from [email protected] npm ERR!   node_modules/browser-sync-webpack-plugin npm ERR!     dev browser-sync-webpack-plugin@"^2.3.0" from the root project npm ERR!  npm ERR! 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!

我尝试将 browser-sync 和 browser-sync-webpack-plugin 的版本更改为同一时间,以便它们兼容。但当我这样做时,我得到了这个:

added 8 packages, changed 3 packages, and audited 859 packages in 5s

86 packages are looking for funding
  run `npm fund` for details

3 moderate severity vulnerabilities

To address all issues (including breaking changes), run:

Run `npm audit` for details.

然后当我输入 npmauditfix --force 时。我收到这条消息:

npm WARN using --force Recommended protections disabled.
npm WARN audit Updating browser-sync to 3.0.2, which is a SemVer major change.
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: sundancecollege.com@undefined
npm WARN Found: [email protected]
npm WARN node_modules/browser-sync
npm WARN   peer browser-sync@"^2" from [email protected]
npm WARN   node_modules/browser-sync-webpack-plugin
npm WARN     dev browser-sync-webpack-plugin@"^2.3.0" from the root project
npm WARN   1 more (the root project)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer browser-sync@"^2" from [email protected]
npm WARN node_modules/browser-sync-webpack-plugin
npm WARN   dev browser-sync-webpack-plugin@"^2.3.0" from the root project

removed 8 packages, changed 3 packages, and audited 851 packages in 4s

86 packages are looking for funding
  run `npm fund` for details

然后将 browser-sync 或 browser-sync-webpack-plugin 的版本更改回原始版本。我也尝试更改 splide.js 的版本,但出现相同的错误。 所以我似乎陷入了循环。

我已经尝试过这里列出的那些使用 webpack 时出现 npm 安装错误,无法解决依赖关系但没有一个对我有用。

这是 package.json 文件信息

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch": "npm run development -- --watch",
        "watch-poll": "npm run watch -- --watch-poll",
        "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js",
        "prod": "npm run production",
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
    },
    "devDependencies": {
        "axios": "^1.6.7",
        "browser-sync": "^3.0.2",
        "browser-sync-webpack-plugin": "^2.3.0",
        "cross-env": "^7.0",
        "laravel-mix": "^6.0.49",
        "lodash": "^4.17.13",
        "resolve-url-loader": "^5.0.0",
        "sass": "^1.15.2",
        "sass-loader": "^8.0.0",
        "vue-template-compiler": "^2.6.14"
    },
    "dependencies": {
        "@github/include-fragment-element": "^5.3.2",
        "@splidejs/splide": "^4.1.4",
        "swiper": "^11.0.5"
    }
}

我已经尝试过这里列出的那些使用 webpack 时出现 npm 安装错误,无法解决依赖关系但没有一个对我有用。

我想在我的 Laravel 网站中运行 splide.js。我将不胜感激任何建议,谢谢!

npm npm-install browser-sync splidejs
2个回答
0
投票

我认为错误来自Browser-Sync-Webpack-plugin,从3年前就没有更新过,而且太旧了

参见: https://github.com/Va1/browser-sync-webpack-plugin/issues/97

解决方案:

从 package.json 中删除 browser-sync-webpack-plugin,然后安装 splidejs 或将 browser-sync 版本从 3 替换为 2


0
投票

您可以暂时使用 browser-sync-v3-webpack-plugin

https://www.npmjs.com/package/browser-sync-v3-webpack-plugin

© www.soinside.com 2019 - 2024. All rights reserved.