title: How to fix the webpack error "version" is a required argument in GCP cloudbuild
body: <p>I create a <a href="https://github.com/webpack/webpack/issues/12229" rel="nofollow noreferrer">bug issue in the webpack repo</a>, but I'm afraid that it'll be closed since they ask for a minimal reproduction, which I cannot produce.</p>
  <p>One of my cloudbuild steps is:</p>
  <pre class="lang-yaml prettyprint-override"><code>- name: node:$_NODE_VERSION
    entrypoint: npm
    args: ['run', 'build:ci'] # with NODE_ENV=production. Skips BundleAnalyzerPlugin
    dir: &quot;v3/client/&quot;
    waitFor: ['css-built', 'secret-available']
    id: 'client-built'
  
  substitutions:
    # Getting errors related to the client/ canvas package using node v15
    #     command failed sh -c node-pre-gyp install --fallback-to-build
    #     No package 'pangocairo' found
    _NODE_VERSION: &quot;14&quot;
  </code></pre>
  <p>It triggers a webpack 4 build as defined below:</p>
  <pre class="lang-json prettyprint-override"><code>  &quot;scripts&quot;: {
      &quot;build:ci&quot;: &quot;NODE_ENV=production npm run build -- --env ci&quot;,
   }
  </code></pre>
  <p>When cloudbuild tries to run the step, it always fails with the following error</p>
  <pre><code>Step #4 - &quot;client-built&quot;: (node:29) UnhandledPromiseRejectionWarning: Error: &quot;version&quot; is a required argument.
  Step #4 - &quot;client-built&quot;:     at Object.getArg (/workspace/v3/client/node_modules/webpack-sources/node_modules/source-map/lib/util.js:24:11)
  Step #4 - &quot;client-built&quot;:     at new BasicSourceMapConsumer (/workspace/v3/client/node_modules/webpack-sources/node_modules/source-map/lib/source-map-consumer.js:294:22)
  Step #4 - &quot;client-built&quot;:     at new SourceMapConsumer (/workspace/v3/client/node_modules/webpack-sources/node_modules/source-map/lib/source-map-consumer.js:22:7)
  Step #4 - &quot;client-built&quot;:     at SourceMapSource.node (/workspace/v3/client/node_modules/webpack-sources/lib/SourceMapSource.js:32:62)
  Step #4 - &quot;client-built&quot;:     at SourceMapSource.proto.sourceAndMap (/workspace/v3/client/node_modules/webpack-sources/lib/SourceAndMapMixin.js:29:18)
  Step #4 - &quot;client-built&quot;:     at getTaskForFile (/workspace/v3/client/node_modules/webpack/lib/SourceMapDevToolPlugin.js:65:30)
  Step #4 - &quot;client-built&quot;:     at /workspace/v3/client/node_modules/webpack/lib/SourceMapDevToolPlugin.js:215:20
  Step #4 - &quot;client-built&quot;:     at Array.forEach (&lt;anonymous&gt;)
  Step #4 - &quot;client-built&quot;:     at /workspace/v3/client/node_modules/webpack/lib/SourceMapDevToolPlugin.js:186:12
  Step #4 - &quot;client-built&quot;:     at SyncHook.eval (eval at create (/workspace/v3/client/node_modules/tapable/lib/HookCodeFactory.js:1:1), &lt;anonymous&gt;:12:1)
  Step #4 - &quot;client-built&quot;:     at SyncHook.lazyCompileHook (/workspace/v3/client/node_modules/tapable/lib/Hook.js:154:20)
  Step #4 - &quot;client-built&quot;:     at /workspace/v3/client/node_modules/webpack/lib/Compilation.js:1413:42
  Step #4 - &quot;client-built&quot;:     at eval (eval at create (/workspace/v3/client/node_modules/tapable/lib/HookCodeFactory.js:1:1), &lt;anonymous&gt;:19:1)
  Step #4 - &quot;client-built&quot;: (Use `node --trace-warnings ...` to show where the warning was created)
  Step #4 - &quot;client-built&quot;: (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 - &quot;client-built&quot;: (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.
  </code></pre>
  <p>This error is very obscure to me, and only happens on cloudbuild, which is very difficult to debug (can't ssh in the environment and debug stuff by myself).</p>
  <p>It seems to have something to do with source-map</p>
  <p>Here are the parts of my config mentioning source maps</p>
  <pre class="lang-js prettyprint-override"><code>export default {
    mode: &quot;production&quot;,
    devtool: &quot;source-map&quot;,
    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: &quot;css-loader&quot;,
            options: {
              importLoaders: 1,
              modules: false,
              sourceMap: true,
            },
          },
        ],
      }, {
        // add source-map support
        enforce: &quot;pre&quot;,
        test: /\.js$/,
        exclude: /node_modules/,
        loader: &quot;source-map-loader&quot;,
      }],
    }
  };
  </code></pre>
  <p>Any idea what could I try to debug this ?</p>
  <p>EDIT: after diffing the webpack config since the last succesfull cloudbuild build, I noticed this change:</p>
  <pre><code>   resolve: {
  -    extensions: [&quot;.ts&quot;, &quot;.tsx&quot;, &quot;.js&quot;, &quot;.jsx&quot;],
  +    // .mjs needed from @apollo/client v3.3.0
  +    extensions: [&quot;.mjs&quot;, &quot;.ts&quot;, &quot;.tsx&quot;, &quot;.js&quot;, &quot;.jsx&quot;],
     },
  </code></pre>
  <p>But webpack supports sourcemap for mjs <a href="https://github.com/webpack/webpack/pull/7947" rel="nofollow noreferrer">since 2018/08</a>, so I guess this is irrelevant.</p>
  <p>The only other change is using the <code>node:14</code> docker image instead of the master one, since node 15 causes errors on npm install since I added <code>canvas</code> to my list of dependencies for jest tests.</p>
  <p>EDIT 2: disabling source maps for my production build works. But that'll be harder to debug production issues from now on  :(</p>