create-react-app: can't run yarn build get issue from Css Minimizer plugin Error: Cannot find module 'normalize-url'

Describe the bug

Can’t build fresh project with yarn build

Did you try recovering your dependencies?

yes ❯ yarn --version 1.22.15

Which terms did you search for in User Guide?

Css Minimizer plugin Error: Cannot find module ‘normalize-url’

Environment

npx create-react-app --info

Environment Info:

current version of create-react-app: 5.0.0 running from C:\Users\kowalski\AppData\Local\Yarn\Data\global\node_modules\create-react-app

System: OS: Windows 10 10.0.19043 CPU: (8) x64 Intel® Xeon® CPU E3-1505M v5 @ 2.80GHz Binaries: Node: 17.4.0 - C:\Files\nodejs17\node.EXE Yarn: 1.22.15 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 8.3.1 - C:\Files\nodejs17\npm.CMD Browsers: Chrome: Not Found Edge: Spartan (44.19041.1266.0), Chromium (97.0.1072.62) Internet Explorer: 11.0.19041.1202 npmPackages: react: ^17.0.2 => 17.0.2 react-dom: ^17.0.2 => 17.0.2 react-scripts: 5.0.0 => 5.0.0 npmGlobalPackages: create-react-app: Not Found

Steps to reproduce

(Write your steps here:)

  1. yarn create react-app my-app2 --template typescript
  2. cd my-app2
  3. yarn build

Expected behavior

should get builded app

Actual behavior

❯ yarn build yarn run v1.22.15 $ react-scripts build Creating an optimized production build… Failed to compile.

static/css/main.a6b5f62b.css from Css Minimizer plugin Error: Cannot find module ‘normalize-url’ Require stack:

  • D:\aaaa\my-app2\node_modules\postcss-normalize-url\dist\index.js
  • D:\aaaa\my-app2\node_modules\cssnano-preset-default\dist\index.js
  • D:\aaaa\my-app2\node_modules\cssnano\dist\index.js
  • D:\aaaa\my-app2\node_modules\css-minimizer-webpack-plugin\dist\minify.js
  • D:\aaaa\my-app2\node_modules\jest-worker\build\workers\threadChild.js image

Reproducible demo

my-app2-for-issue.zip

About this issue

Most upvoted comments

yes i faced the same issue , i solved it

Failed to compile.

static/css/main.be5a105b.css from Css Minimizer plugin Error: Invalid mapping: {“generated”:{“line”:1,“column”:3846},“source”:“static/css/main.be5a105b.css”,“original”:{“line”:1368,“column”:null},“name”:null}

error Command failed with exit code 1.

I get a simular message to this issue above after updating from CRA4 to 5.

I fixed it bgy going through all css files in the project commenting out the whole file until this error goes away. Then going back thorugh re-instanting rules until I found the problematic bit.

So if you are getting this you have some invaild css, but you get no clue in the error as to where, and must spend ages doing a manual binary search of your codebase.

yarn add --dev postcss-normalize it worked for me

any workaround @anazbinnoushad pls ?

I tried to figure out your code problem and solved this way. First, remove your build folder and yarn.lock file, then, yarn install and then yarn build that is it, it works here : )