ベスパリブ

ベスパもってないです。バイク買いました。

`Unhandled rejection Error: original.line and original.column are not numbers` エラーの解消

--mode=developではエラーは発生せず、--mode=productionで以下のコマンドを打つとエラーが発生した。

$ ./node_modules/webpack-cli/bin/cli.js --mode=production
Unhandled rejection Error: original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.
    at SourceMapGenerator_validateMapping [as _validateMapping] (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\webpack-sources\node_modules\source-map\lib\source-map-generator.js:276:15)
    at SourceMapGenerator_addMapping [as addMapping] (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\webpack-sources\node_modules\source-map\lib\source-map-generator.js:110:12)
    at C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\webpack-sources\node_modules\source-map\lib\source-map-generator.js:72:17
    at Array.forEach (<anonymous>)
    at BasicSourceMapConsumer.SourceMapConsumer_eachMapping [as eachMapping] (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\webpack-sources\node_modules\source-map\lib\source-map-consumer.js:157:14)
    at Function.SourceMapGenerator_fromSourceMap [as fromSourceMap] (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\webpack-sources\node_modules\source-map\lib\source-map-generator.js:48:24)
    at SourceMapSource.node (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\webpack-sources\lib\SourceMapSource.js:32:35)
    at SourceMapSource.proto.sourceAndMap (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\webpack-sources\lib\SourceAndMapMixin.js:30:18)
    at getTaskForFile (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\webpack\lib\SourceMapDevToolPlugin.js:37:30)
    at files.forEach (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\webpack\lib\SourceMapDevToolPlugin.js:136:20)
    at Array.forEach (<anonymous>)
    at compilation.hooks.afterOptimizeChunkAssets.tap (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\webpack\lib\SourceMapDevToolPlugin.js:130:12)
    at SyncHook.eval [as call] (eval at create (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\tapable\lib\HookCodeFactory.js:19:10), <anonymous>:7:1)
    at SyncHook.lazyCompileHook (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\tapable\lib\Hook.js:154:20)
    at hooks.optimizeChunkAssets.callAsync.err (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\webpack\lib\Compilation.js:1315:42)
    at _err0 (eval at create (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:11:1)
    at taskRunner.run (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\terser-webpack-plugin\dist\index.js:319:9)
    at step (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\terser-webpack-plugin\dist\TaskRunner.js:87:9)
    at _cacache.default.get.then (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\terser-webpack-plugin\dist\TaskRunner.js:111:15)
    at tryCatcher (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\bluebird\js\release\promise.js:517:31)
    at Promise._settlePromise (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\bluebird\js\release\promise.js:574:18)
    at Promise._settlePromise0 (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\bluebird\js\release\promise.js:619:10)
    at Promise._settlePromises (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\bluebird\js\release\promise.js:699:18)
    at Promise._fulfill (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\bluebird\js\release\promise.js:643:18)
    at Promise._resolveCallback (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\bluebird\js\release\promise.js:437:57)
    at Promise._settlePromiseFromHandler (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\bluebird\js\release\promise.js:529:17)
    at Promise._settlePromise (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\bluebird\js\release\promise.js:574:18)
    at Promise._settlePromise0 (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\bluebird\js\release\promise.js:619:10)
    at Promise._settlePromises (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\bluebird\js\release\promise.js:699:18)
    at Promise._fulfill (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\bluebird\js\release\promise.js:643:18)
    at Promise._resolveCallback (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\bluebird\js\release\promise.js:437:57)
    at Promise._settlePromiseFromHandler (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\bluebird\js\release\promise.js:529:17)
    at Promise._settlePromise (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\bluebird\js\release\promise.js:574:18)
    at Promise._settlePromise0 (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\bluebird\js\release\promise.js:619:10)
    at Promise._settlePromises (C:\Users\XXXX\workspace\MyProject\MyProject\node_modules\bluebird\js\release\promise.js:699:18)

とりあえずエラー内容でググると、似たような現象の記事を見つけられる。

ざっと見るとsource mapのエラーかな?というのが当たりがつくので、webpack.config.js 内のdevtool: "source-map",を試しにコメントアウト

module.exports = {
    mode: 'development',
    entry: './src/content.js',
    output: {
        path: __dirname + "/dst",
        filename: 'content.js',
    },
    optimization: {
        minimize: true,
    },
    //devtool: "source-map",
    module: {
        rules: [
            {
                test: /\.js$/, // .jsファイルを処理対象として指定
                exclude: /node_modules/,
                use: {  // test プロパティにマッチしたファイルに対する処理を指定
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env']
                    }
                }
            }
        ]
    }
};

するとエラーが消え無事ビルドできました。ちなみによくわかっていません。