3
respostas

Erro npm run build-dev Cannot find module 'webpack.config.js'

> client@1.0.0 build-dev C:\Users\Lais\Documents\Projetos\projeto-webpack\client
> webpack --config webpack.config.js

internal/modules/cjs/loader.js:983
  throw err;
  ^

Error: Cannot find module 'C:\Users\Lais\Documents\Projetos\projeto-webpack\client\webpack.config.js'
Require stack:
- C:\Users\Lais\Documents\Projetos\projeto-webpack\client\node_modules\webpack\bin\convert-argv.js
- C:\Users\Lais\Documents\Projetos\projeto-webpack\client\node_modules\webpack\bin\webpack.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
    at Function.Module._load (internal/modules/cjs/loader.js:862:27)
    at Module.require (internal/modules/cjs/loader.js:1042:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at requireConfig (C:\Users\Lais\Documents\Projetos\projeto-webpack\client\node_modules\webpack\bin\convert-argv.js:97:18)
    at C:\Users\Lais\Documents\Projetos\projeto-webpack\client\node_modules\webpack\bin\convert-argv.js:104:17
    at Array.forEach (<anonymous>)
    at module.exports (C:\Users\Lais\Documents\Projetos\projeto-webpack\client\node_modules\webpack\bin\convert-argv.js:102:15)
    at C:\Users\Lais\Documents\Projetos\projeto-webpack\client\node_modules\webpack\bin\webpack.js:171:41
    at Object.Yargs.self.parse (C:\Users\Lais\Documents\Projetos\projeto-webpack\client\node_modules\yargs\yargs.js:533:18) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\Lais\\Documents\\Projetos\\projeto-webpack\\client\\node_modules\\webpack\\bin\\convert-argv.js',
    'C:\\Users\\Lais\\Documents\\Projetos\\projeto-webpack\\client\\node_modules\\webpack\\bin\\webpack.js'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client@1.0.0 build-dev: `webpack --config webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client@1.0.0 build-dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Lais\AppData\Roaming\npm-cache\_logs\2021-04-26T20_27_48_236Z-debug.log

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"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "reflect-metadata": "^0.1.10"
  },
  "devDependencies": {
    "babel-core": "^6.25.0",
    "babel-loader": "^7.1.0",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-preset-es2017": "^6.24.1",
    "webpack": "^3.1.0"
  }
}

webpack.config.js

const path = require('path');

module.exports = {
    entry: './app-src/app.js',
    output: {
        filename: 'bundle.js', //nome do bundle a ser criado
        path: path.resolve(__dirname, 'dist')
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader'
                }
            }
        ]
    }
}

babelrc

{
    "presets":["es2017"],
    "plugins" : ["transform-decorators-legacy"]
}
3 respostas

Boa noite Lais, tudo joia?

Seu arquivo webpack.config.js está dentro do diretório /client ?

Boa noite! Tudo bem e você?

Está sim!

Está dando um erro de MODULE_NOT_FOUND, não está encontrando algum módulo. Posta aqui seu webpack.config.js para analisarmos, pode ser? (Se quiser tentar reinstalar o webpack para fazer um teste).