Я попытался использовать веб-пакет сегодня, и я наткнулся на эту ошибку «Ошибка сборки модуля», «Ошибка синтаксиса» - PullRequest
0 голосов
/ 31 января 2020

Получаю эту ошибку с тех пор, как я начал использовать веб-пакет сегодня, и мне интересно узнать и как ее решить

  • Попытался удалить все пакеты babel
  • И также попытался переустановите их заново ): SyntaxError: C: \ Users \ User \ Desktop \ WorkStation \ 9-forkify.babelr c: Ошибка при разборе конфигурации - JSON5: недопустимый символ ',' в 8:39 при синтаксической ошибке (C: \ Users \ User \ Desktop \ WorkStation \ 9-forkify \ node_modules@babel \ core \ node_modules \ json5 \ lib \ parse. js: 1083: 17) в invalidChar (C: \ Users \ Пользователь \ Desktop \ WorkStation \ 9-forkify \ node_modules@babel \ core \ node_modules \ json5 \ lib \ parse. js: 1028: 12) в Object.afterPropertyName (C: \ Users \ Пользователь \ Desktop \ WorkStation \ 9-forkify \ node_modules@babel \ core \ node_modules \ json5 \ lib \ parse. js: 640: 15) в Object.default (C: \ Users \ Пользователь \ Desktop \ WorkStation \ 9-forkify \ node_modules@babel \ core \ node_modules \ json5 \ Lib \ Парс e. js: 146: 37) в lex (C: \ Users \ Пользователь \ Desktop \ WorkStation \ 9-forkify \ node_modules@babel \ core \ node_modules \ json5 \ lib \ parse. js: 78: 42) в Object.parse (C: \ Users \ Пользователь \ Desktop \ WorkStation \ 9-forkify \ node_modules@babel \ core \ node_modules \ json5 \ lib \ parse. js: 25: 17) в C : \ Users \ Пользователь \ Desktop \ WorkStation \ 9-forkify \ node_modules@babel \ core \ lib \ config \ files \ configuration. js: 239: 31 в C: \ Users \ Пользователь \ Desktop \ WorkStation \ 9 -forkify \ node_modules@babel \ core \ lib \ config \ files \ utils. js: 37: 12 в Generator.next () в функции. (C: \ Users \ User \ Desktop \ WorkStation \ 9-forkify \ node_modules@babel \ core \ lib \ gensyn c -utils \ asyn c. js: 26: 3) в Generator.next () atvaluSyn c (C: \ Users \ Пользователь \ Desktop \ WorkStation \ 9-forkify \ node_modules \ gensync \ index. js: 244: 28) в Function.syn c (C : \ Users \ Пользователь \ Desktop \ WorkStation \ 9-forkify \ node_modules \ gensync \ index. js: 84: 14) в syn c (C: \ Users \ Пользователь \ Desktop \ WorkStation \ 9-forkify \ node_modules@babel \ core \ lib \ gensyn c -utils \ asyn c. js: 66: 25) в syn c (C: \ Users \ Пользователь \ Desktop \ WorkStation \ 9- forkify \ node_modules \ gensync \ index. js: 177: 19) в onFirstPause (C: \ Users \ Пользователь \ Desktop \ WorkStation \ 9-forkify \ node_modules \ gensync \ index. js: 204: 19) в Generator.next () в cachedFunction (C: \ Users \ Пользователь \ Desktop \ WorkStation \ 9-forkify \ node_modules@babel \ core \ lib \ config \ caching. js: 68: 46) в cachedFunction.next () atvaluSyn c (C: \ Users \ Пользователь \ Desktop \ WorkStation \ 9-forkify \ node_modules \ gensync \ index. js: 244: 28) в C: \ Users \ User \ Desktop \Работает tation \ 9-forkify \ node_modules \ gensync \ index. js: 31: 34 в Array.map () в Function.syn c (C: \ Users \ Пользователь \ Desktop \ WorkStation \ 9-forkify \ node_modules \ gensync \ index. js: 31: 22) в Function.all (C: \ Users \ Пользователь \ Desktop \ WorkStation \ 9-forkify \ node_modules \ gensync \ index. js: 204: 19) в Generator.next () в loadOneConfig (C: \ Users \ Пользователь \ Рабочий стол \ WorkStation \ 9-forkify \ node_modules@babel \ core \ lib \ config \ files \ configuration. js: 130: 45) в loadOneConfig .next () в findRelativeConfig (C: \ Users \ Пользователь \ Desktop \ WorkStation \ 9-forkify \ node_modules@babel \ core \ lib \ config \ files \ configuration. js: 105: 23) в findRelativeConfig.next () в buildRootChain (C: \ Users \ Пользователь \ Desktop \ WorkStation \ 9-forkify \ node_modules@babel \ core \ lib \ config \ config-chain. js: 113: 46) @ multi @ babel / polyfill ./src/js/index.js main [1]

    Webpack.config. js

        const path = require('path')
        const HtmlWebpackPlugin = require('html-webpack-plugin')     
    
       module.exports = {
        entry: ["@babel/polyfill", "./src/js/index.js"],
        output: {
            path: path.resolve(__dirname, 'dist'), 
            filename: 'js/bundle.js'
        }, 
        devServer: {
            contentBase: './dist'
        }, 
        plugins: [
            new HtmlWebpackPlugin({ 
                filename: 'index.html',
                template: './src/index.html'
            })
        ], 
        module: {
            rules: [
                {
                    test:/\.js$/, 
                    exclude: '/node_modules/',
                    use: {
                        loader:'babel-loader'
                    }
                }
            ]
        }
    }
    

    Пакет . json

    {
      "name": "forkify",
      "version": "1.0.0",
      "description": "forkify project",
      "main": "index.js",
      "scripts": {
        "dev": "webpack --mode development",
        "build": "webpack --mode production"
      },
      "author": "iamgabrielsoft",
      "license": "ISC",
      "devDependencies": {
        "@babel/cli": "^7.8.4",
        "@babel/core": "^7.8.4",
        "@babel/preset-env": "^7.8.4",
        "babel-loader": "^8.0.6",
        "html-webpack-plugin": "^3.2.0",
        "webpack": "^4.41.5",
        "webpack-cli": "^3.3.10"
      },
      "dependencies": {
        "@babel/polyfill": "^7.8.3"
      }
    }
    

    .babelr c

     {
        "presets": [
          [
            "@babel/preset-env",
            {
              "targets": {
                  "browsers": {
                      "last five versions", 
                      "ie >= 8"
                  }
              }
            }
          ]
        ]
      }
    
...