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

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

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

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

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

  1. const path = require("path");
  2. const webpack = require("webpack");
  3. module.exports = {
  4. entry: {
  5. javascript: "./src/index.js"
  6. },
  7. mode: "development",
  8. module: {
  9. rules: [
  10. {
  11. test: /\.(js|jsx|mjs)$/,
  12. exclude: /(node_modules|bower_components)/,
  13. loader: "babel-loader",
  14. options: {
  15. "presets": ["@babel/preset-env", "@babel/preset-react"],
  16. "plugins": ["@babel/plugin-transform-regenerator", "transform-class-properties"]
  17. }
  18. },
  19. {
  20. test: /\.css$/,
  21. use: ["style-loader", "css-loader"]
  22. },
  23. { test: /\.(png|woff|woff2|eot|ttf|svg)$/,
  24. use: [
  25. {
  26. loader: 'url-loader',
  27. options: {
  28. limit: 8192,
  29. name: '[name].[ext]',
  30. publicPath: 'public/asset/'
  31. },
  32. },
  33. ],
  34. }
  35. ]
  36. },
  37. resolve: { extensions: ["*", ".js", ".jsx", ".html", ".mjs"] },
  38. output: {
  39. path: path.resolve(__dirname, "dist/"),
  40. publicPath: "/dist/",
  41. filename: "bundle.js",
  42. },
  43. node: {
  44. net: 'empty',
  45. fs: 'empty',
  46. dgram: 'empty',
  47. tls: 'empty',
  48. dns: 'empty',
  49. http2: 'empty'
  50. },
  51. devServer: {
  52. contentBase: path.join(__dirname, "public/"),
  53. port: 3000,
  54. publicPath: "http://localhost:3000/dist/",
  55. hotOnly: true,
  56. historyApiFallback: true
  57. },
  58. plugins: [new webpack.HotModuleReplacementPlugin()]
  59. };

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

  1. "devDependencies": {
  2. "@babel/cli": "^7.1.0",
  3. "@babel/core": "^7.1.0",
  4. "@babel/preset-env": "^7.1.0",
  5. "@babel/preset-react": "^7.0.0",
  6. "babel-loader": "^8.0.2",
  7. "css-loader": "^1.0.0",
  8. "file-loader": "^6.2.0",
  9. "style-loader": "^0.23.0",
  10. "url-loader": "^4.1.1",
  11. "webpack": "^4.19.1",
  12. "webpack-cli": "^3.1.1",
  13. "webpack-dev-server": "^3.1.8"
  14. },
  15. "dependencies": {
  16. "@babel/plugin-transform-runtime": "^7.12.17",
  17. "@blueprintjs/core": "^3.39.0",
  18. "@blueprintjs/select": "^3.15.5",
  19. "babel-plugin-transform-class-properties": "^6.24.1",
  20. "enzian-yellow": "file:../enzian-yellow",
  21. "fs-extra": "^4.0.3",
  22. "react": "^16.5.2",
  23. "react-dom": "^16.5.2",
  24. "react-hot-loader": "^4.3.11",
  25. "react-json-view": "^1.21.1",
  26. "react-router-dom": "^5.2.0",
  27. "web3": "1.3.3"
  28. }

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

暂无答案!

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

相关问题