Error: "version" is a required argument
See original GitHub issueBug report
What is the current behavior? My webpack setup works fine in my local environment but fails in GCP cloudbuild with an obscure error.
Step #4 - "client-built": (node:29) UnhandledPromiseRejectionWarning: Error: "version" is a required argument.
Step #4 - "client-built": at Object.getArg (/workspace/v3/client/node_modules/webpack-sources/node_modules/source-map/lib/util.js:24:11)
Step #4 - "client-built": at new BasicSourceMapConsumer (/workspace/v3/client/node_modules/webpack-sources/node_modules/source-map/lib/source-map-consumer.js:294:22)
Step #4 - "client-built": at new SourceMapConsumer (/workspace/v3/client/node_modules/webpack-sources/node_modules/source-map/lib/source-map-consumer.js:22:7)
Step #4 - "client-built": at SourceMapSource.node (/workspace/v3/client/node_modules/webpack-sources/lib/SourceMapSource.js:32:62)
Step #4 - "client-built": at SourceMapSource.proto.sourceAndMap (/workspace/v3/client/node_modules/webpack-sources/lib/SourceAndMapMixin.js:29:18)
Step #4 - "client-built": at getTaskForFile (/workspace/v3/client/node_modules/webpack/lib/SourceMapDevToolPlugin.js:65:30)
Step #4 - "client-built": at /workspace/v3/client/node_modules/webpack/lib/SourceMapDevToolPlugin.js:215:20
Step #4 - "client-built": at Array.forEach (<anonymous>)
Step #4 - "client-built": at /workspace/v3/client/node_modules/webpack/lib/SourceMapDevToolPlugin.js:186:12
Step #4 - "client-built": at SyncHook.eval (eval at create (/workspace/v3/client/node_modules/tapable/lib/HookCodeFactory.js:1:1), <anonymous>:12:1)
Step #4 - "client-built": at SyncHook.lazyCompileHook (/workspace/v3/client/node_modules/tapable/lib/Hook.js:154:20)
Step #4 - "client-built": at /workspace/v3/client/node_modules/webpack/lib/Compilation.js:1413:42
Step #4 - "client-built": at eval (eval at create (/workspace/v3/client/node_modules/tapable/lib/HookCodeFactory.js:1:1), <anonymous>:19:1)
Step #4 - "client-built": (Use `node --trace-warnings ...` to show where the warning was created)
Step #4 - "client-built": (node:29) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
Step #4 - "client-built": (node:29) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
If the current behavior is a bug, please provide the steps to reproduce.
cloudbuild step:
- name: node:$_NODE_VERSION
entrypoint: npm
args: ['run', 'build:ci'] # with NODE_ENV=production. Skips BundleAnalyzerPlugin
dir: "v3/client/"
waitFor: ['css-built', 'secret-available']
id: 'client-built'
package.json
"scripts": {
"build:ci": "NODE_ENV=production npm run build -- --env ci",
}
I have a complex setup and the issue is specifically with google cloud platform’s cloudbuild service. Can someone give me hints as to how debug and resolve this issue by myself ?
Since the traceback refers to source-map, here are parts of my config that have something to do with source maps:
config extract
export default {
mode: "production",
devtool: "source-map",
optimization: {
minimizer: [
new TerserPlugin({
sourceMap: true, // Must be set to true if using source-maps in production
terserOptions: {
compress: {
drop_console: true,
},
output: {
comments: false,
},
},
}),
]
},
module: {
rules: [{
test: /\.css$/i,
use: [
{
loader: "css-loader",
options: {
importLoaders: 1,
modules: false,
sourceMap: true,
},
},
],
}, {
// add source-map support
enforce: "pre",
test: /\.js$/,
exclude: /node_modules/,
loader: "source-map-loader",
}],
}
};
What is the expected behavior? No “UnhandledPromiseRejectionWarning” exception should be thrown.
Other relevant information: webpack version: 4.44.2 (cannot use v5 due to issues with apollo-upload-client and graphql-js) Node.js version: 14 on cloudbuild (cannot use v15 due to other errors with node-canvas+node-pre-gyp+pangocairo) Operating System: cloudbuild is using the official node docker image Additional tools:
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
I confirm that upgrading css-minimizer-webpack-plugin to the latest version fixed the issue, thanks!
No problems with any version of terser, so it was due
css-minimizer-webpack-plugin
(I think your problem here due you provide only part of configuration) or some source maps doesn’t have theversion
property ofsource-map-loader
, feel free to feedback