Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

Erro antigo

ReferenceError: npm is not defined at Object. (C:\Users\NOTE\Downloads\Projeto webpack\projeto-webpack\client\webpack.config.js:3:1) at Module.compile (internal/modules/cjs/loader.js:1137:30) at Object.Module.extensions..js (internal/modules/cjs/loader.js:1157:10) at Module.load (internal/modules/cjs/loader.js:985:32) at Function.Module.load (internal/modules/cjs/loader.js:878:14) at Module.require (internal/modules/cjs/loader.js:1025:19) at require (internal/modules/cjs/helpers.js:72:18) at requireConfig (C:\Users\NOTE\Downloads\Projeto webpack\projeto-webpack\client\nodemodules\webpack\bin\convert-argv.js:97:18) at C:\Users\NOTE\Downloads\Projeto webpack\projeto-webpack\client\node_modules\webpack\bin\convert-argv.js:104:17 at Array.forEach () npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! client@1.0.0 start: webpack-dev-server npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the client@1.0.0 start 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\NOTE\AppData\Roaming\npm-cache_logs\2020-11-10T17_28_28_899Z-debug.log

3 respostas

Fala ai Rubens, tudo bem? Consegue compartilhar o conteúdo do arquivo webpack.config.js? Se possível, compartilha também o conteudo do package.json e o comando que está executando para dar esse erro.

Fico no aguardo.

{
  "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": "NODE_ENV=production webpack --config webpack.config.js",
    "start": "webpack-dev-server"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bootstrap": "^3.3.7",
    "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",
    "babili-webpack-plugin": "^0.1.1",
    "cross-env": "^5.0.1",
    "webpack": "^3.1.0",
    "webpack-dev-server": "^2.5.1"
  }
}

const path = require('path');
const babiliPlugin = require('babili-webpack-plugin');
npm
let plugins = [];

if(process.env.NODE_ENV == 'production') {

    plugins.push(new babiliPl());
}

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

}
solução!

Fala ai Rubens, o problema é porque tem um npm solto no seu webpack.config.js, logo após o require do babili-webpack-plugin e antes da declaração dos plugins:

const path = require('path');
const babiliPlugin = require('babili-webpack-plugin');
npm
let plugins = [];

Tente remover ele:

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

let plugins = [];

O problema deve resolver.

Espero ter ajudado.