question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERROR TypeError: (void 0) is not a function - prod build issue

See original GitHub issue

Bug report

What is the current behavior? Throwing ERROR TypeError: (void 0) is not a function in the production build.

If the current behavior is a bug, please provide the steps to reproduce. I am working on a simple d3.js project. In the production build, I am getting this error.

Webpack.config.js

const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');


module.exports = {
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'example.bundle.js',
    libraryTarget: 'var',
    library: 'ExampleProject',
    libraryExport: 'default'
  },
  devtool: 'inline-source-map',
  devServer: {
    contentBase: path.resolve(__dirname, 'dist'),
    compress: true,
    watchContentBase: true,
    port: 9000
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader"
        }
      },
      {
        test: /\.scss$/,
        use: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: ['css-loader', 'sass-loader']
        })
      }
    ]
  },
  plugins: [
    new CleanWebpackPlugin(['dist']),
    new ExtractTextPlugin({ filename: 'style.css' }),
    new HtmlWebpackPlugin({
      inject: false,
      hash: true,
      template: './src/index.html',
      filename: 'index.html'
    })
  ]
};

package.json

{
  "name": "es6_example",
  "version": "1.0.0",
  "description": "",
  "main": "dist/example.bundle.js",
  "scripts": {
    "dev": "webpack --mode development",
    "build": "webpack --mode production ",
    "start": "webpack-dev-server --mode development --watch-poll",
    "prepublish": "npm run build"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.4",
    "babel-preset-env": "^1.7.0",
    "clean-webpack-plugin": "^1.0.0",
    "css-loader": "^1.0.1",
    "d3": "^5.7.0",
    "extract-text-webpack-plugin": "^4.0.0-beta.0",
    "html-webpack-plugin": "^3.2.0",
    "node-sass": "^4.10.0",
    "sass-loader": "^7.1.0",
    "style-loader": "^0.23.1",
    "uglifyjs-webpack-plugin": "^2.0.1",
    "webpack": "^4.25.1",
    "webpack-cli": "^3.1.2",
    "webpack-dev-server": "^3.1.10"
  }
}

What is the expected behavior? Prod build also should work as development build, but it isn’t.

Other relevant information: webpack version: 4.25.1 Node.js version: 12.13.0 Operating System: Ubuntu 16 Additional tools:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
navinnacommented, Jun 1, 2020

I fixed this issue by installing and using babel-preset-es2015, babel-preset-stage-0 as follows in module.rules

{ test: /\.js$/, exclude: /node_modules/, use: [{ loader: "babel-loader", options: { presets: ['es2015', 'stage-0']} }] }

0reactions
mcjambicommented, Feb 24, 2022

i have the same error, and it caused by import .env in webpack.common.ts !

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: (void 0) is not a function when closing modal
When I close the state (modal) it keeps coming up with the error message: TypeError: (void 0) is not a function.
Read more >
How do you fix the "javascript: void(0)" error? - Quora
This means that when the browser attempts to load a new page it sees null and has nothing to load. here is no...
Read more >
(void 0) is not a function using d3 with angular 7-d3.js
To anyone having the same issue, the problem is that angular build optimizer is removing too much code (minifying) and that is why...
Read more >
Netlify TypeError (void 0) is not a function (500 Internal Error)
I deployed my website (as usual) and for some reason it builds and deploys okay (no error), but when I reach the website's...
Read more >
(void 0) is not a constructor" when adding properties to web ...
Now it fails (sort of) by throwing the following cryptic error: "TypeError: (void 0) is not a constructor" What is especially interesting is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found