1
resposta

Erro: __webpack_require__ is not defined

Estou pegando essa exceção na hora de acessar a página em http://localhost:8080.

Uncaught ReferenceError: __webpack_require__ is not defined
    at eval (webpack:///multi_(:8080/webpack)-dev-server/client?:1:1)
    at Object.0 (bundle.js:1)
    at t (bundle.js:1)
    at bundle.js:1
    at bundle.js:1

package.json

{
  "name": "client",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build-dev": "webpack --config webpack.config.js",
    "build-prod": "cross-env NODE_ENV=production webpack --config webpack.config.js",
    "start": "webpack-dev-server"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "reflect-metadata": "^0.1.10"
  },
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.5",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-preset-es2017": "^6.24.1",
    "babili-webpack-plugin": "^0.1.2",
    "cross-env": "^6.0.3",
    "webpack": "^4.41.2",
    "webpack-cli": "^3.3.10",
    "webpack-dev-server": "^3.9.0"
  }
}

webpack.config.js

const path = require('path');
const babiliPlugin = require('babili-webpack-plugin');

let plugins = [];
if (process.env.NODE_ENV = 'production') {
    plugins.push(new babiliPlugin());
}

module.exports = {
    entry: './app-src/app.js',
    output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname, 'dist'),
        publicPath: 'dist'
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node-modules/,
                use: {
                    loader: 'babel-loader'
                }
            }
        ]
    },
    plugins
}
1 resposta

Fala ai Reinaldo, tudo bem? Olhando os códigos parecem estar corretos, mas, posso ter deixado passar algum detalhe.

Você consegue compartilhar o projeto completo? Assim eu consigo simular o problema por aqui e analisá-lo com mais calma.

Fico no aguardo.

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software