簡體   English   中英

Webpack 無法在已經工作的節點 package 中編譯 js

[英]Webpack unable to compile js in already working node package

我正在嘗試對使用補丁包安裝的節點 package 進行一些樣式更改,為此我必須使用 webpack 來編譯 src/ 目錄中的代碼以在 dist/ 中獲取新代碼。 當我運行 npx webpack 時,我收到以下錯誤:

ERROR in ./src/index.js 189:12
Module parse failed: Unexpected token (189:12)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|     render() {
|         return (
>             <div>

這個節點 package 開箱即用,我提醒你。 我不確定我在這里缺少什么。 package 除了默認配置文件之外沒有任何配置文件。 這是里面的東西:

rules: [
      {
        test: /\.js$/,
        include: path.resolve(__dirname, 'src'),
        exclude: /(node_modules|bower_components|build)/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env']
          }
        }
      },

提前致謝!

編輯:刪除 node_modules & package-lock 並重新安裝並不能解決問題

清理你的 node_modules 並重新安裝軟件包可能會有所幫助。

暫無
暫無

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

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