ariandanim

ariandanim

(HELP) Upgrading NPM in assets folder Phoenix Framework

My App Spec:

  • Erlang/OTP 23 [erts-11.1.5] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]
  • Elixir 1.11.3 (compiled with Erlang/OTP 23)
  • Phoenix 1.5.7
  • NPM version 7.3.0
  • Node Js version 15.5.0

when i try to access the assets folder then typing "npm install"it shows like this:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: webpack@5.12.2
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.45.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!

Then i try to install node modules in assets folder typing "npm install --legacy-peer-deps"then show like this:

npm WARN deprecated urix@0.1.0: Please see GitHub - lydell/urix: [DEPRECATED] Makes Windows-style paths more unix and URI friendly. · GitHub
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated resolve-url@0.2.1: GitHub - lydell/resolve-url: [DEPRECATED] Like Node.js’ `path.resolve`/`url.resolve` for the browser. · GitHub
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142

added 913 packages, and audited 916 packages in 3m

44 packages are looking for funding
run npm fund for details

found 0 vulnerabilities

i am wondering what the the warn deprecated above, so i typed in assets folder "npm outdated"then shows like this:

Package Current Wanted Latest Location Depended by
copy-webpack-plugin 5.1.2 5.1.2 7.0.0 node_modules/copy-webpack-plugin assets
css-loader 3.6.0 3.6.0 5.0.1 node_modules/css-loader assets
mini-css-extract-plugin 0.9.0 0.9.0 1.3.3 node_modules/mini-css-extract-plugin assets
node-sass 4.14.1 4.14.1 5.0.0 node_modules/node-sass assets
sass-loader 8.0.2 8.0.2 10.1.0 node_modules/sass-loader assets
terser-webpack-plugin 2.3.8 2.3.8 5.1.1 node_modules/terser-webpack-plugin assets
webpack 4.41.5 4.41.5 5.12.2 node_modules/webpack assets
webpack-cli 3.3.12 3.3.12 4.3.1 node_modules/webpack-cli assets

Question is, does is safe if i upgrading my assets folder the NPM plugin?

Most Liked

kokolegorille

kokolegorille

Hello and welcome…

Yes it is, but as for all major changes, You need update configuration. This time it’s webpack going to version 5.

You might follow this post about PR to Upgrade to webpack 5 - #12 by webuhu

kokolegorille

kokolegorille

… with the help of this package.

https://www.npmjs.com/package/npm-check-updates

You need to know that there might be some breaking changes when updating, and You need to configure those files…

assets/webpack.config.js

Be sure to follow PR update path

config/dev.exs

Update this part.

  watchers: [
    node: [
      "node_modules/webpack/bin/webpack.js",
      "--mode",
      "development",
      "--watch",
      "--watch-options-stdin",
      cd: Path.expand("../assets", __DIR__)
    ]
  ]

This is a simple example of ncu, from the assets folder.

$ ncu
Checking /...
[====================] 29/29 100%

 terser-webpack-plugin  ^5.1.0  →  ^5.1.1   
 webpack                5.12.1  →  5.12.3   

Run ncu -u to upgrade package.json

As You can see there are some minor changes, and it’s probably safe to run ncu -u. But if You see some majors changing… You need to check for configuration update.

This is not really Phoenix related, but by default it uses Webpack to bundle your assets.

kokolegorille

kokolegorille

You need to install it with

npm install -g npm-check-updates

Where Next?

Popular in Questions Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29377 241
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New

We're in Beta

About us Mission Statement