Nextjs error when first run: Error: Cannot find module 'caniuse-lite/data/features/css-unicode-bidi'

Viewed 490

I got error when start my nextjs project, here's the error

error - ./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[2]!./styles/globals.css

Error: Cannot find module 'caniuse-lite/data/features/css-unicode-bidi'

and got this require stack

Require stack:

- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/compiled/postcss-preset-env/index.cjs
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/build/webpack/config/blocks/css/plugins.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/build/webpack/config/blocks/css/index.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/build/webpack/config/index.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/build/webpack-config.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/server/dev/hot-reloader.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/server/dev/next-dev-server.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/server/next.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/server/lib/start-server.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/cli/next-dev.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/lib/commands.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/bin/next

I've tried to install next js with yarn and npm but still i got this problem

4 Answers

This is an issue with caniuse-lite which was introduced in v1.0.30001394 and fixed in v1.0.30001397. See browserslist/caniuse-lite#100.

To fix it, update to latest version.

npm install caniuse-lite@1.0.30001397

downgrading the version of caniuse-lite to below seems to fix the issue

npm i caniuse-lite@1.0.30001390

The only thing that works for me was to find the file css-unicode-bidi.js from another project.

I paste it in /node_modules/caniuse-lite/data/features/ directory and after this the app works again!

Related