da2k / curso-reactjs-ninja

917 stars 322 forks source link

MRW#02 Configuração do Webpack #595

Closed biaaPrado closed 2 years ago

biaaPrado commented 2 years ago

Instalei os pacotes corretamente, mas ao rodar o comando webpack, aparece o seguinte erro

webpack
/home/bia/react-webpack/webpack.config.js:6
    entry: path.join(_dirname, 'src', 'index'),
                     ^

ReferenceError: _dirname is not defined
    at Object.<anonymous> (/home/bia/react-webpack/webpack.config.js:6:22)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at module.exports (/home/bia/.npm-global/lib/node_modules/webpack/bin/convert-argv.js:80:13)
    at Object.<anonymous> (/home/bia/.npm-global/lib/node_modules/webpack/bin/webpack.js:39:40)
    at Module._compile (internal/modules/cjs/loader.js:999:30)

Comparando o arquivo webpack.config.js está identico ao mostrado na aula

'use strict'

const path = require('path')

module.exports = {
    entry: path.join(_dirname, 'src', 'index'),
    output:{
        path: path.join(_dirname, 'dist'),
        filename: 'bundle.js'
    }
}

@fdaciuk

fdaciuk commented 2 years ago

Oi @biaaPrado! Essa variável começa com dois underlines: __dirname =)