question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

normalize-url@1.9.1 dependency is not compatible with Webpack@5 out of the box

See original GitHub issue
  • Operating System: Ubuntu
  • Node Version: 12.19.0
  • NPM Version: 6.14.8
  • webpack Version: 5.1.2
  • mini-css-extract-plugin Version: 1.0.0

Actual Behavior

I am in the progress of upgrading my React toolset to Webpack@5. Running a compilation of some codebase I got the following error message

ModuleNotFoundError: Module not found: Error: Can't resolve 'url' in '/home/birdofprey/Documents/dr.pogodin.studio/react-utils/node_modules/normalize-url'
          
          BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
          This is no longer the case. Verify if you need this module and configure a polyfill for it.
          
          If you want to include a polyfill, you need to:
          	- add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
          	- install 'url'
          If you don't want to include a polyfill, you can use an empty module like this:
          	resolve.fallback: { "url": false }

I did not have a chance to dig deeper into it yet, and probably update the ticket with more info in the following days, but after a very brief look I found the following:

  1. Only two packages within dependencies depend on normalize-url: this one (on v1.9.1), and optimize-css-assets-webpack-plugin (on 3.3.0).
  2. A note in normalize-url page mentions if you need to use this in browser, use version 4+, thus I guess the latest normalize-url should work with Webpack@5 out of the box, with no need of fallbacks.
  3. I noticed this PR in past, which downgrated normalize-url: https://github.com/webpack-contrib/mini-css-extract-plugin/pull/399

Taking all these into account, I decided to already create this ticket, to check if somebody arounds knows more about it: is it still needed to keep old normalize-url around? Is it possible to upgrade to its latest version, or drop/replace that dependency by something else?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
birdofpreyrucommented, Oct 16, 2020

@evilebottnawi Huge thanks for the remark about migration to css-minimizer!

Regarding this ticket, the problem is that to use this (mini-css-extract-plugin) with Webpack@5, at least in some corner-cases one needs to add resolve.fallback.url: require.resolve('url') to his Webpack config, and install url package as the dependency. It solves the issue for me, but this looks like an avoidable inconvenience, caused by you depending on legacy version of normalize-url.

1reaction
alexander-akaitcommented, Oct 16, 2020

Do not use optimize-css-assets-webpack-plugin migrate to https://github.com/webpack-contrib/css-minimizer-webpack-plugin

Read more comments on GitHub >

github_iconTop Results From Across the Web

resolve.fallback: { "url": false } - You.com - You.com
This is what I'll be using for now until I can find a better solution. Open side panel. Module not found: Error: Can't...
Read more >
Upgrade to Webpack 5 failing - node.js - Stack Overflow
You need to fix scripts/start.js file. There is a line in this file: const compiler = createCompiler(webpack, config, appName, urls, ...
Read more >
Npm package installation error on other partition
I'm getting this error whenever I install a package from npm on another partition: npm ERR! code 126 npm ERR! path ...
Read more >
Relay
The Relay compiler will then ensure that the data dependencies declared in such fragments are fetched as part of that parent query. import...
Read more >
Web Libraries in Jars - WebJars
angular-translate-loader-url, org.webjars, angular-translate-loader-url ... org.webjars.bower, bootstrap-star-rating-fork-boostrap-dependency, 3.5.4.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found