Fl4m3Ph03n1x
Unable to run `npm install` in fresh Phoenix project on Powershell windows
Background
I am trying to do a Phoenix LiveView project to learn how it works. To this extent, I have, in my windows 10 machine, installed Elixir and NPM via chocolatey. I have also successfully run the commands:
$ mix archive.install hex phx_new
$ mix phx.new demo --live
Problem
The problem comes after running the second command. After its completion I am told to follow some additional steps:
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
In specific, the npm install part fails:
> 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
This is a fresh project. I am confused as to why this is even happening.
If I run npm install --force then I am greeted with a wall of errors, I assume because of this issue.
Question
How can I fix this?
Marked As Solved
chulkilee
There you go. You’re using node 15, which has npm 7 by default. You’re hitting this issue:
https://github.com/npm/cli/issues/2514
https://github.com/webpack-contrib/mini-css-extract-plugin/blob/v0.9.0/package.json#L38-L40
As the issue says, you can workaround the bug with npm i --legacy-peer-deps.
(I also reported the example to the github issue)
So.. if you don’t need new feature, then probably better to stick with LTS nodejs and “latest” npm - which is node 14 / npm 6.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









