如何在运行构建时解决错误的笑话工人? [英] how solve error jest-worker at run build?
问题描述
我在运行webpack的生产时遇到问题。但是当我使用开发服务器运行时,更多的代码不会出错。请帮助..我必须完成我的上一个项目,并且它必须以良好的生产模式运行。我希望我能从你们那里得到解决方案。
i have a problem at run build production in webpack. but when i run using dev-server, more code can't get error. please help.. I have to finish my last project and it must run with good at production mode. I hope I get a solution from you guys.
在运行构建时出现的错误:
here my error at run build:
/MovieDB/node_modules/jest-worker/build/WorkerPool.js:25
} catch {
^
SyntaxError: Unexpected token {
at NativeCompileCache._moduleCompile (/home/donquixote/Desktop/dicoding-submission/MovieDB/node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
at Module._compile (/home/donquixote/Desktop/dicoding-submission/MovieDB/node_modules/v8-compile-cache/v8-compile-cache.js:186:36)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
...
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
此处是我的webpack.common.js:
here my webpack.common.js:
const path = require('path');
const webpack = require('webpack');
const HtmlPackPlugin = require('html-webpack-plugin');
const terserPlugin = require('terser-webpack-plugin');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
plugins: [
new HtmlPackPlugin({
template: './src/index.html',
filename: 'index.html'})
],
optimization: {
minimize: true,
minimizer: [
new terserPlugin({
test: /\.js(\?.*)?$/i,
})
],
sourceMap: true
}
}
此处我的webpack.dev.js
here my webpack.dev.js
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: "development",
devtool: 'inline-source-map'
})
推荐答案
您使用的是哪个Node.js版本?
what's the version of Node.js are you using?
我在运行最新的3.0.2版本的terser-webpack-plugin时遇到了相同的错误。根据发布日志,3.0.0中引入了一些重大更改,其中之一是最低支持的Node.js版本是10.13
I ran into the same error when I was running the latest terser-webpack-plugin @ 3.0.2. According to the release log, there were some breaking changes introduced in 3.0.0 and one of them was "minimum supported Node.js version is 10.13"
将terser-webpack-plugin降级到2.3.6。
It worked when I downgraded terser-webpack-plugin to 2.3.6.
因此,如果您使用的版本早于10.13,则可能必须升级Node.js或降级terser-webpack-plugin。
So you'll probably have to upgrade your Node.js if you're using a version earlier than 10.13, or downgrade your terser-webpack-plugin.
这篇关于如何在运行构建时解决错误的笑话工人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!