エラー
% 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.
解決
/config/webpack/environment.js
に以下を追加
const { environment } = require('@rails/webpacker')
const customConfig = {
resolve: {
fallback: {
dgram: false,
fs: false,
net: false,
tls: false,
child_process: false
}
}
};
environment.config.delete('node.dgram')
environment.config.delete('node.fs')
environment.config.delete('node.net')
environment.config.delete('node.tls')
environment.config.delete('node.child_process')
environment.config.merge(customConfig);
module.exports = environment
参考URL
【Ruby on Rails】rails6とwebpack5で発生したエラーを解決するまでの長い道のり - TKGBlog
【解決】Your Yarn packages are out of date! Please run `yarn install` to update. #Rails - Qiita