ruby-on-rails 已使用与API架构不匹配的配置对象初始化Webpack

rqqzpn5f  于 2023-01-22  发布在  Ruby
关注(0)|答案(1)|浏览(191)
    • bounty将在5天后过期**。回答此问题可获得+50声望奖励。Ronan Louarn希望引起更多人关注此问题。

使用Ruby on Rails(6.1.4.4),并在将webpack从4.46.0升级到5.67.0以及将webpack-cli从版本3.3.12升级到4.9.2后不断收到以下错误:

root@b26d476dafbd:/myapp$ bin/webpack
[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration.node should be one of these:
   false | object { __dirname?, __filename?, global? }
   -> Include polyfills or mocks for various node stuff.
   Details:
    * configuration.node has an unknown property 'dgram'. These properties are valid:
      object { __dirname?, __filename?, global? }
      -> Options object for node compatibility features.
    * configuration.node has an unknown property 'fs'. These properties are valid:
      object { __dirname?, __filename?, global? }
      -> Options object for node compatibility features.
    * configuration.node has an unknown property 'net'. These properties are valid:
      object { __dirname?, __filename?, global? }
      -> Options object for node compatibility features.
    * configuration.node has an unknown property 'tls'. These properties are valid:
      object { __dirname?, __filename?, global? }
      -> Options object for node compatibility features.
    * configuration.node has an unknown property 'child_process'. These properties are valid:
      object { __dirname?, __filename?, global? }
      -> Options object for node compatibility features.

下面是我的package.json的一个例子:

{
  "name": "vspm",
  "private": true,
  "dependencies": {
    "@claviska/jquery-minicolors": "^2.3.6",
    "@rails/activestorage": "^7.0.1",
    "@rails/ujs": "^7.0.1",
    "@rails/webpacker": "5.4.3",
    "add": "^2.0.6",
    "bootstrap": "5.1.3",
    "bootstrap4-tagsinput": "^4.1.3",
    "bufferutil": "^4.0.6",
    "cocoon": "github:nathanvda/cocoon#c24ba53",
    "datatables.net": "^1.11.4",
    "datatables.net-bs4": "^3.2.2",
    "google-libphonenumber": "^3.2.26",
    "intl-tel-input": "^17.0.15",
    "jquery": "^3.6.0",
    "jquery-mask-plugin": "^1.14.16",
    "justgage": "^1.5.1",
    "moment": "^2.29.1",
    "node-waves": "^0.7.6",
    "popper.js": "^1.16.1",
    "raphael": "^2.3.0",
    "textlint": "^12.1.0",
    "utf-8-validate": "^5.0.8",
    "webpack": "^5.67.0",
    "webpack-cli": "^4.9.2",
    "yarn": "^1.22.17"
  },
  "description": "This README would normally document whatever steps are necessary to get the application up and running.",
  "version": "1.0.0",
  "main": "pdf.js",
  "directories": {
    "lib": "lib",
    "test": "test"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/altjx/goku.git"
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/altjx/goku/issues"
  },
  "homepage": "https://github.com/altjx/goku#readme",
  "devDependencies": {
    "@babel/plugin-transform-strict-mode": "^7.16.7",
    "webpack-dev-server": "^4.7.3"
  }
}

不太确定是什么导致了升级。不幸的是,我甚至不确定错误消息到底指向了什么地方。

lawou6xi

lawou6xi1#

看起来在webpack4中设置了节点多边形填充,但在webpack5中删除了自动节点多边形填充
在webpack5中设置多边形填充的简单方法是npm i node-polyfill-webpack-plugin . in webpack.config.js

const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");

plugins: [
  new NodePolyfillPlugin(),
],

相关问题