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

Problema ao rodar npm run build-dev

quando dou este comando dá a seguinte mensagem de erro

> client@1.0.0 build-dev D:\Cursojs\projeto-webpack\client
> webpack --config webpack.config.js
Hash: f6825daca3353766dfbb
Version: webpack 3.1.0
Time: 901ms
    Asset  Size  Chunks             Chunk Names
bundle.js  4 kB       0  [emitted]  main
   [0] ./app-src/app.js 1.53 kB {0} [built] [failed] [1 error]

ERROR in ./app-src/app.js
Module build failed: ReferenceError: Unknown plugin "transform-es2015-modules-systemjs" specified in "D:\\Cursojs\\projeto-webpack\\client\\.babelrc" at 0, attempted to resolve relative to "D:\\Cursojs\\projeto-webpack\\client"
    at D:\Cursojs\projeto-webpack\client\node_modules\babel-core\lib\transformation\file\options\option-manager.js:180:17
    at Array.map (<anonymous>)
    at Function.normalisePlugins (D:\Cursojs\projeto-webpack\client\node_modules\babel-core\lib\transformation\file\options\option-manager.js:158:20)        
    at OptionManager.mergeOptions (D:\Cursojs\projeto-webpack\client\node_modules\babel-core\lib\transformation\file\options\option-manager.js:234:36)       
    at OptionManager.init (D:\Cursojs\projeto-webpack\client\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
    at File.initOptions (D:\Cursojs\projeto-webpack\client\node_modules\babel-core\lib\transformation\file\index.js:212:65)
    at new File (D:\Cursojs\projeto-webpack\client\node_modules\babel-core\lib\transformation\file\index.js:135:24)
    at Pipeline.transform (D:\Cursojs\projeto-webpack\client\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
    at transpile (D:\Cursojs\projeto-webpack\client\node_modules\babel-loader\lib\index.js:49:20)
    at Object.module.exports (D:\Cursojs\projeto-webpack\client\node_modules\babel-loader\lib\index.js:171:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! client@1.0.0 build-dev: `webpack --config webpack.config.js`
npm ERR! Exit status 2
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\antho\AppData\Roaming\npm-cache\_logs\2020-12-15T19_46_33_547Z-debug.log

Meu webpack.config.js é :

const path = require('path');

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

e meu 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"
  }
}
2 respostas

Fala ai Anthoni, tudo bem? Acho que faltou você instalar o pacote transform-es2015-modules-systemjs como dependência de desenvolvimento do projeto:

npm i -D transform-es2015-modules-systemjs

Depois de instalá-la, tente buildar a aplicação novamente.

Espero ter ajudado.

solução!

Bom dia chefe beleza? Então, você já retirou o

transform-es2015-modules-systemjs

da sua aplicação?Se não, você precisa desinstalá-lo da suas dependências de desenvolvedor e retirar o loader do systemjs do HTML .

Use o comando npm uninstall transform-es2015-modules-systemjs --save-dev

Como é o Babel Core que vai transcompilar o código do ES6 em ES2015 para você e o Webpack vai fazer o bundle do JS, você precisa retirá-lo e verificar se não tem nenhum require('transform-es2015-modules-systemjs') no projeto, seja no HTML no App.js ou no .babelrc :D

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