React - Minified exception occurred

旧城冷巷雨未停 提交于 2019-11-27 02:02:51

问题


I have React js installed via NPM and using browserify to manage components in react. When an exception occurs in React, the console shows as

"Uncaught Error: Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings."

How do I enable full error messages ?


回答1:


Setting NODE_ENV to development as Benjamin Gruenbaum pointed out in the comment resolved the issues.

set NODE_ENV=development



回答2:


If you are encountering this issue with Karma + Webpack, the following Webpack configuration fixed the issue for me when running tests:

plugins: [
    new webpack.DefinePlugin({
        'process.env': {
            NODE_ENV: JSON.stringify('development')
        }
    })
]



回答3:


I FINALLY SOLVED THIS.

If you're like me and ran that command to set NODE_ENV and it's literally never worked, check if you're linking to react.min.js instead of the full versions of the files.

Link to the full versions and it should work like a charm. :D




回答4:


If you are using jspm to bundle your code, note that version 0.16.24 imports the minified "production" version of React, which throws this error. My temporary solution was to downgrade jspm to 0.16.23.

edit Future versions of jspm will allow you to declare production vs. development versions (see jspm beta documentation)




回答5:


I had this issue, and for me I didn't need to disable minification or use react source. My script was just loading before the root element. So I just moved the script out of the head and below the div in the index file source code and that fixed it.

Changed my index.jade from this:

html
 head
   title Super coo site
   script(src="bundle.js")
 body
   div#root

To this:

html
 head
   title Super coo site
 body
   div#root
   script(src="bundle.js")



回答6:


Have you check the DOM element that you are trying render ? I had this error before due to a silly mistake. The worst part is bundle was minified. The element id is not same

Index.html

<div id="ds-app"></div>

app.jsx

React.DOM.render(<App/>, document.getElementById('app'))



回答7:


As of version 15.2, production React error messages (NODE_ENV=production) now include a URL that you can visit where you can see the original, unobfuscated error.

https://twitter.com/dan_abramov/status/748969886433546240

You should consider upgrading to React 15.2 in order to get access to these error messages. Additionally, some production crash reporting tools automatically unminify these errors for you.




回答8:


use the min.js files in production or bundle your application code with process.env.NODE_ENV === 'production' and you should be good to go!




回答9:


If your package.json scripts has dll, try exec npm run dll or yarn run dll.




回答10:


I got this error when my render method returned undefined eg

render() {
    let view;
    // Not paying attention and slip a case where view won't get assigned a value
    if(this.props.foo == 'hello') {
        view = <HelloView />
    }
    else if(this.props.foo == 'bye') {
        view = <ByeView />
    }
    return view;
}

This will trigger the error when this.props.foo is 'hi'



来源:https://stackoverflow.com/questions/29586928/react-minified-exception-occurred

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!