Webpack error: Can't resolve 'fbjs/lib/EventListener'

Webpack error: Can't resolve 'fbjs/lib/EventListener'

我正在尝试将 React 添加到我现有的网络应用程序中。我成功安装了所有必需的 npm 模块,但是在 运行 npm run wbp 命令之后我遇到了很多错误,例如:

ERROR in ./node_modules/react-dom/cjs/react-dom.production.min.js
Module not found: Error: Can't resolve 'fbjs/lib/EventListener'

ERROR in ./node_modules/react/cjs/react.production.min.js
Module not found: Error: Can't resolve 'object-assign'

Webpack 版本:

Version: webpack 4.1.1

我的webpack.config.js:

const path = require('path');

module.exports = {
    entry: path.join(__dirname, '/wwwroot/js/stats.jsx'),
    output: {
        path: path.join(__dirname, 'wwwroot/js/'),
        filename: 'admin.js'
    },
    resolve: {
        extensions: ['.jsx']
    },
    module: {
        rules: [
            {
                test: /\.jsx?$/,
                loader: 'babel-loader',
                query: {
                    cacheDirectory: true,
                    presets: ['@babel/preset-react', '@babel/preset-env']
                }
            }
        ]
    }
};

我的package.json:

    {
  "name": "WebSite",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "wbp": "webpack --display-error-details --mode production"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/core": "^7.0.0-beta.40",
    "@babel/preset-env": "^7.0.0-beta.40",
    "@babel/preset-react": "^7.0.0-beta.40",
    "babel-loader": "^8.0.0-beta.0",
    "cjs": "0.0.11",
    "fbjs": "^0.8.16",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "webpack": "^4.1.1",
    "webpack-cli": "^2.0.10"
  }
}

我试图通过手动映射到 fbjs 的路径来解决这个问题,但没有成功。我做错了什么?

UPD: webpack --display-error-details --mode development 为我生成了 admin.js 但也显示了错误。在这种情况下,浏览器控制台显示 react.development.js:17 Uncaught Error: Cannot find module "object-assign" 错误

终于成功了:

我的package.json:

{
  "name": "WebSite",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "wbp": "webpack --display-error-details --mode development"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "react": "^15.4.2",
    "react-dom": "^15.4.2"
  },
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.4",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "webpack": "^4.1.1",
    "webpack-cli": "^2.0.11",
    "webpack-config": "^7.0.0"
  }
}

我的webpack.config.js:

const path = require('path');


module.exports = {
    entry: path.join(__dirname, 'wwwroot/js/Admin/stats.jsx'),
    output: {
        path: path.join(__dirname, 'wwwroot/js/Admin'),
        filename: 'admin.js'
    },
    resolve: {
        extensions: ['.jsx', '.js']
    },
    module: {
        rules: [{
            test: /\.jsx?$/,
            loader: 'babel-loader',
            query:
                {
                    presets:['react']
                }
        }]
    },
};