Encountered “Minified React error” in the production environment
See original GitHub issueDescribe the bug
Encountered “Minified React error” in the production environment, the dev environment is fine.
error: Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=object&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at vc (vendor.93c27df6.js:23)
at d (vendor.93c27df6.js:23)
at vendor.93c27df6.js:23
at vendor.93c27df6.js:23
at Ts (vendor.93c27df6.js:23)
at ul (vendor.93c27df6.js:23)
at ic (vendor.93c27df6.js:23)
at tc (vendor.93c27df6.js:23)
at ql (vendor.93c27df6.js:23)
at zl (vendor.93c27df6.js:23)
Reproduction
Repo: https://github.com/songquanpeng/snippet-manager/tree/aa02a582c676bd3dcd5254f18d7087bb8a1a7220
My React application is on the web
folder.
System Info
vite
version: 2.0.0- Operating System: Windows 10
- Node version: v14.15.3
- Package manager (npm/yarn/pnpm) and version: 7.5.4
Summarization of the root problem
https://github.com/vitejs/vite/issues/2139#issuecomment-1024852072
Issue Analytics
- State:
- Created 3 years ago
- Reactions:52
- Comments:77 (15 by maintainers)
Top Results From Across the Web
Error: Minified React error #130 [duplicate] - Stack Overflow
Error: Minified React error #130. The full text of the error you just encountered is: Element type is invalid: expected a string (for ......
Read more >Minified React error #130 - The Draftbit Community
Has someone seen this and if so provide some guidance. Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]= ...
Read more >Gatsby fails to build pages on netlify: WebpackError: Minified ...
Gatsby fails to build pages on netlify: WebpackError: Minified React error #65; ... My site builds fine locally. On Netlify it crashes when...
Read more >React Full Calendar creating Minified React error #130
Upon deployment, my app works great except when I try to navigate to the calendar page. The calendar does not render and throws...
Read more >Getting this error, please help: "Minified React error #31"
Error: Minified React error #31; visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=TypeError%3A%20Cannot%20read%20property% ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m completely lost as to how Vite works internally so I am unable to help, but I will add that the library that was giving me issues is https://www.npmjs.com/package/react-phone-input-2, and the fix for now is the one suggested by @haikyuu:
I ran into the same issue using latest Vite version.
Note
The title of the issue is very vague as this error is displayed by minified React instead of ANY React error. So it can be anything really. But in both our cases, this is the actual error
Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
The first thing to do in this case is to debug the app in order to have more details: Use minify and dev mode in your
vite.config.js
in order to get the real issue with the possibility to inspect in the browser dev tools.Hacky solution in my case
In my case it was coming from using
react-switch
. And I hacked it to work using the following (don’t tell anyone about this)Basically this is the content of the import
{__esModule: true, default: ƒ}
The react-switch library is built as
cjs
so this is probably acjs
compatibility issue for Vite’s Rollup build configuration ?In the reproduction repo
If you follow the debugging steps, you will discover that the culprit in your case is react-highlight
Notes for reproduction
In order to reproduce the issue, you need to:
npx vite build
npx http-server dist --port 3002