how solve error jest-worker at run build?
Asked Answered
A

2

13

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.

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
  }
}

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'
})
Applewhite answered 25/5, 2020 at 13:43 Comment(0)
C
30

what's the version of Node.js are you using?

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"

It worked when I downgraded terser-webpack-plugin to 2.3.6.

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.

Cathee answered 28/5, 2020 at 20:29 Comment(2)
This helps in my caseImprovise
I was using node v10.19.xx and when I upgraded to 18.12.0 everything worked as expected. thanks @CatheeJeaniejeanine
E
6

This is what did the job for me, for kinda similar error

node_modules/eslint-webpack-plugin/node_modules/jest-worker/build/index.js:110
 _ending;
     ^

SyntaxError: Unexpected token ;

I was also using an older version of node, and when I did

nvm use 16.15.1

which is the latest version I have installed, it started working.

Evante answered 13/7, 2023 at 9:13 Comment(2)
thank you for your answer, but i have already solved for this issue.Applewhite
@iman-fauzi I am genuinely happy for you, but since our issues were not 100% the same and someone can potentially have use out of my own experience, I posted nevertheless. Thanks for the upvote, I appreciate.Evante

© 2022 - 2024 — McMap. All rights reserved.