大佬教程收集整理的这篇文章主要介绍了未捕获的 ReferenceError:添加 react-hot-loader babel 插件后未定义进程(来自 NodeJS.Process),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在升级了一些依赖项和包后遇到了这个问题。我希望使用最新版本的 TypeScript,因此我添加了一些 babel 插件并进行了一些其他更改。
我能够编译我的代码,但在运行我的应用程序时出现此控制台错误:
Uncaught ReferenceError: process is not defined
at storeConfig.tsx:4
at Module../src/store/storeConfig.tsx (bundle.Js?4d48cc1c51da72536add:55462)
at __webpack_require__ (bootstrap:24)
at fn (hot module replacement:61)
at Module../src/index.tsx (history.ts:2)
at __webpack_require__ (bootstrap:24)
at startup:5
at startup:6
这是我如何配置我的商店:
import {applyMIDdleware,compose,createStore,Store} from "redux";
import thunk from "redux-thunk";
import appReducers,{AppState} from "../combinedReducers";
declare let process: NodeJs.Process;
declare let window: any;
export const mIDdleware = [
thunk
];
export const configureStore = () => {
const isDevelopment = process.env.NODE_ENV === 'development';
const enhancers: any[] = isDevelopment && window.__Redux_DEVTOolS_EXTENSION__ && window.__Redux_DEVTOolS_EXTENSION__() ? [window.__Redux_DEVTOolS_EXTENSION__()] : [];
return createStore(
appReducers,compose(applyMIDdleware(thunk),...enhancers)
) as Store<AppState>;
};
export default configureStore;
此代码之前运行良好。我不确定发生了什么变化。
我会说我在将“react-hot-loader/babel”添加回我的开发 webpack 配置文件的插件后确实注意到了这个问题。
{
test: /\.tsx$|.ts$/,include: path.join(__dir@R_403_6889@,'src'),exclude: /node_modules/,use: {
loader: "babel-loader",options: {
cacheDirectory: true,babelrc: false,presets: [
"@babel/preset-env","@babel/preset-typescript","@babel/preset-react"
],plugins: [
["@babel/plugin-proposal-class-propertIEs",{loose: true}],"@babel/plugin-proposal-numeric-separator","@babel/plugin-transform-typescript","@babel/plugin-proposal-nullish-coalescing-operator","@babel/plugin-proposal-optional-chaining","@babel/plugin-transform-runtime","react-hot-loader/babel"
]
}
}
},
奇怪的是,如果我从上面的列表中删除该插件,它就可以正常工作。但是,我想要热重载功能。有什么想法吗?
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的未捕获的 ReferenceError:添加 react-hot-loader babel 插件后未定义进程(来自 NodeJS.Process)全部内容,希望文章能够帮你解决未捕获的 ReferenceError:添加 react-hot-loader babel 插件后未定义进程(来自 NodeJS.Process)所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。