我的创建反应应用程序有问题。当我运行dev版本时一切都很好。当我尝试运行构建版本时,我收到错误:
未捕获错误:locals [0]似乎不是启用了热模块替换API的module
对象。您应该在Babel配置中使用env
部分禁用生产中的react-transform-hmr。请参阅自述文件中的示例:https://github.com/gaearon/react-transform-hmr
at n(react-datepicker.js:4634)
我试过这个:babel.rc文件
{
"presets": ["es2015", "stage-0"],
"env": {
// only enable it when process.env.NODE_ENV is 'development' or undefined
"development": {
"plugins": [[
"react-transform", {
"transforms": [{
"transform": "react-transform-hmr",
// if you use React Native, pass "react-native" instead:
"imports": ["react"],
// this is important for Webpack HMR:
"locals": ["module"]
}]
// note: you can put more transforms into array
// this is just one of them!
}
]]
}
}
}
我的构建命令是:
“build”:“设置NODE_ENV =生产&& react-scripts build”, 知道为什么会这样,或者我应该在哪里寻找解决方案? 感谢