小编Pet*_*uis的帖子

Webpack ReferenceError:未定义 require (ReactJS)

require()我知道当在浏览器中调用该函数而不是在节点内调用该函数时会发生此错误。但是,我似乎不明白我到底需要做什么来解决这个问题。任何帮助将不胜感激。您可以访问以下存储库以获取整个代码库https://github.com/thegreekjester/React_SSR

运行并重现问题的步骤:

  • npm 安装
  • npm 运行开发
  • localhost:3000在浏览器中打开
  • 您将在控制台中看到错误

Webpack.client.js

const path = require('path');
const webpackNodeExternals = require('webpack-node-externals');

module.exports = {

  // production || development
  mode: 'development',

  // Inform webpack that we're building a bundle
  // for nodeJS, rather then for the browser
  target: 'node',

  // Tell webpack the root file of our
  // server application
  entry: './src/client.js',

  // Tell webpack where to put the output file
  // that is generated
  output: {
    filename: 'client_bundle.js',
    path: path.resolve(__dirname, …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs webpack redux react-redux

1
推荐指数
1
解决办法
4613
查看次数

标签 统计

javascript ×1

react-redux ×1

reactjs ×1

redux ×1

webpack ×1