react应用程序:Web包无法加载某些结构通用依赖项

uqjltbpv  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(170)

这可能不是一个与织物直接相关的问题,但它只是在包含织物之后才出现在我身上。
我在“enzian yellow”库中构建了一个基于结构的bpm引擎。react应用程序“chrysalis”安装了enzian yellow,但当我尝试启动该应用程序时,出现以下错误:

Module parse failed: Unexpected token (18:41)
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
| const REQUIRE_DIRECTORY_ERROR = 'loading a directory of commands is not supported yet for ESM'
|
> const mainFilename = fileURLToPath(import.meta.url).split('node_modules')[0]
| const __dirname = fileURLToPath(import.meta.url)
|
 @ ../enzian-yellow/node_modules/fabric-common/node_modules/nconf/node_modules/yargs/index.mjs 4:0-59 7:28-43
 @ ../enzian-yellow/node_modules/fabric-common/node_modules/nconf/lib/nconf/stores/argv.js
 @ ../enzian-yellow/node_modules/fabric-common/node_modules/nconf/lib/nconf/stores sync ^\.\/.*$
 @ ../enzian-yellow/node_modules/fabric-common/node_modules/nconf/lib/nconf.js
 @ ../enzian-yellow/node_modules/fabric-common/lib/Config.js
 @ ../enzian-yellow/node_modules/fabric-common/index.js
 @ ../enzian-yellow/node_modules/fabric-ca-client/lib/FabricCAServices.js
 @ ../enzian-yellow/node_modules/fabric-ca-client/index.js
 @ ../enzian-yellow/lib/hyperledger/hyperledger-accessor.js
 @ ../enzian-yellow/lib/hyperledger/index.js
 @ ../enzian-yellow/lib/index.js
 @ ./src/components/Deploy.js
 @ ./src/index.js

由于恩赞黄的测试运行顺利,我认为这确实是一个加载器问题,但我不知道要改变什么。
webpack.config.js

const path = require("path");
const webpack = require("webpack");

module.exports = {
  entry: {
    javascript: "./src/index.js"
  },
  mode: "development",
  module: {
    rules: [
      {
        test: /\.(js|jsx|mjs)$/,
        exclude: /(node_modules|bower_components)/,
        loader: "babel-loader",
        options: {
          "presets": ["@babel/preset-env", "@babel/preset-react"],
          "plugins": ["@babel/plugin-transform-regenerator", "transform-class-properties"]
        }
      },
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"]
      },
      { test: /\.(png|woff|woff2|eot|ttf|svg)$/, 
        use: [
          {
            loader: 'url-loader',
            options: {
              limit: 8192,
              name: '[name].[ext]',
              publicPath: 'public/asset/'
            },
          },
        ],

      }

    ]
  },
  resolve: { extensions: ["*", ".js", ".jsx", ".html", ".mjs"] },
  output: {
    path: path.resolve(__dirname, "dist/"),
    publicPath: "/dist/",
    filename: "bundle.js",
  },
  node: {
    net: 'empty',
    fs: 'empty',
    dgram: 'empty',
    tls: 'empty',
    dns: 'empty',
    http2: 'empty'
  },

  devServer: {
    contentBase: path.join(__dirname, "public/"),
    port: 3000,
    publicPath: "http://localhost:3000/dist/",
    hotOnly: true,
    historyApiFallback: true
  },
  plugins: [new webpack.HotModuleReplacementPlugin()]
};

请注意,“node”属性上的“empty”参数也是必需的,因此@grpc lib能够解析这些常量。
依赖关系

"devDependencies": {
    "@babel/cli": "^7.1.0",
    "@babel/core": "^7.1.0",
    "@babel/preset-env": "^7.1.0",
    "@babel/preset-react": "^7.0.0",
    "babel-loader": "^8.0.2",
    "css-loader": "^1.0.0",
    "file-loader": "^6.2.0",
    "style-loader": "^0.23.0",
    "url-loader": "^4.1.1",
    "webpack": "^4.19.1",
    "webpack-cli": "^3.1.1",
    "webpack-dev-server": "^3.1.8"
  },
  "dependencies": {
    "@babel/plugin-transform-runtime": "^7.12.17",
    "@blueprintjs/core": "^3.39.0",
    "@blueprintjs/select": "^3.15.5",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "enzian-yellow": "file:../enzian-yellow",
    "fs-extra": "^4.0.3",
    "react": "^16.5.2",
    "react-dom": "^16.5.2",
    "react-hot-loader": "^4.3.11",
    "react-json-view": "^1.21.1",
    "react-router-dom": "^5.2.0",
    "web3": "1.3.3"
  }

我试着改变了很多版本,但似乎没有任何帮助。有什么建议吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题