【发布时间】:2021-05-03 04:31:18
【问题描述】:
背景
我正在尝试做一个Phoenix LiveView 项目来了解它是如何工作的。在这个程度上,我已经在我的 Windows 10 机器上通过chocolatey 安装了 Elixir 和 NPM。我也成功运行了命令:
$ mix archive.install hex phx_new
$ mix phx.new demo --live
问题
运行第二个命令后出现问题。完成后,我被告知要执行一些额外的步骤:
We are almost there! The following steps are missing:
$ cd test_app
$ cd assets && npm install && node node_modules/webpack/bin/webpack.js --mode development
具体来说,npm install 部分失败:
> npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: webpack@5.18.0
npm ERR! node_modules/webpack
npm ERR! dev webpack@"4.41.5" from the root project
npm ERR! peer webpack@">=2" from babel-loader@8.2.2
npm ERR! node_modules/babel-loader
npm ERR! dev babel-loader@"^8.0.0" from the root project
npm ERR! 3 more (copy-webpack-plugin, css-loader, hard-source-webpack-plugin)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! dev mini-css-extract-plugin@"^0.9.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: webpack@4.46.0
npm ERR! node_modules/webpack
npm ERR! peer webpack@"^4.4.0" from mini-css-extract-plugin@0.9.0
npm ERR! node_modules/mini-css-extract-plugin
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! See C:\Users\user\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Local\npm-cache\_logs\2021-01-29T08_41_13_010Z-debug.log
这是一个新项目。我很困惑为什么会发生这种情况。
如果我运行npm install --force,那么我会遇到一连串错误,我认为是因为这个问题。
问题
我该如何解决这个问题?
【问题讨论】:
-
你能把你
package.json的内容贴出来吗?似乎某些依赖项需要不同的 webpack 版本,这会导致冲突。另外,webpack -v对您来说是终端上的有效命令吗?它显示了什么?
标签: npm webpack elixir npm-install phoenix-framework