簡體   English   中英

npm 運行構建上的 Babel-Loader 語法錯誤

[英]Babel-Loader Syntax error on npm run build

我對 webpack 不是很強大,我正在嘗試將 webpack 從 V3 更新到 V4,並設法將我的 webpack 配置更新到了從 babel-loader 出現的語法錯誤,但我現在沒有在 babel-loader 上拋出語法錯誤:

      Module build failed (from ./node_modules/babel-loader/lib/index.js):
      /path/react/node_modules/schema-utils/dist/util/hints.js:16
      const currentSchema = { ...schema
      SyntaxError: Unexpected token ...

在我的 webpack 配置中,我有這個:

         test: /\.(js|jsx)$/,
            use: [
              {
                loader: 'babel-loader',
                options: {
                  presets: [
                    '@babel/preset-env',
                    '@babel/preset-react',
                    {
                      plugins: [
                        '@babel/plugin-proposal-class-properties'
                      ]
                    }
                  ],
                  compact: true,
                  cacheDirectory: false, // @todo: legacy option: true
                },
              }
            ]

我正在使用以下版本:

 "@babel/core": "^7.1.6",
 "@babel/plugin-proposal-class-properties": "^7.8.3",
 "@babel/preset-env": "^7.1.6",
 "@babel/preset-react": "^7.0.0",
 "babel-loader": "^8.0.4",

我曾多次嘗試使用不同版本的 babel,但總是以這條消息結束。 誰能看到我犯的任何明顯錯誤?

SyntaxError: Unexpected token...意味着您的節點沒有轉譯 ES6。 您是否將 node/npm 升級到相對較新的版本?

另外,如果您要更改版本,我建議您在再次運行npm install之前刪除您的node_modules文件夾和package-lock.json文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM