Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: G6 v5.0.43 is getting an error when starting in a vue2 project #6809

Open
2 of 10 tasks
2014guai opened this issue Feb 26, 2025 · 1 comment
Open
2 of 10 tasks
Labels
waiting for maintainer Triage or intervention needed from a maintainer.

Comments

@2014guai
Copy link

2014guai commented Feb 26, 2025

Describe the bug / 问题描述

 error  in ./node_modules/.pnpm/[email protected]/node_modules/ml-matrix/src/symmetricMatrix.js

Module parse failed: Unexpected character '#' (8: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/conc
epts#loaders
| export class SymmetricMatrix extends AbstractMatrix {
|   /** @type {Matrix} */
>   #matrix;
|
|   get size() {

 @ ./node_modules/.pnpm/[email protected]/node_modules/ml-matrix/src/index.js 2:0-34 2:0-34
 @ ./node_modules/.pnpm/@[email protected][email protected]/node_modules/@antv/layout/lib/mds.js
 @ ./node_modules/.pnpm/@[email protected][email protected]/node_modules/@antv/layout/lib/exports.js
 @ ./node_modules/.pnpm/@[email protected][email protected]/node_modules/@antv/layout/lib/index.js
 @ ./node_modules/.pnpm/@[email protected][email protected]/node_modules/@antv/g6/esm/layouts/index.js
 @ ./node_modules/.pnpm/@[email protected][email protected]/node_modules/@antv/g6/esm/exports.js
 @ ./node_modules/.pnpm/@[email protected][email protected]/node_modules/@antv/g6/esm/index.js
 @ ./node_modules/.pnpm/[email protected][email protected]/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/.pnpm/[email protected]_@ba
[email protected][email protected]/node_modules/babel-loader/lib!./node_modules/.pnpm/[email protected][email protected]/node_modules/cache-loader/dist/cjs
.js??ref--0-0!./node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/vue
-loader/lib??vue-loader-options!./src/views/index.vue?vue&type=script&lang=js
 @ ./src/views/index.vue?vue&type=script&lang=js
 @ ./src/views/index.vue
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi ./node_modules/.pnpm/[email protected][email protected]/node_modules/webpack-dev-server/client?http://192.168.10.114:80&sockPath=/sockj
s-node (webpack)/hot/dev-server.js ./src/main.js

如图,启动报错

Reproduction link / 复现链接

No response

Steps to Reproduce the Bug or Issue / 重现步骤

No response

Version / 版本

Please select / 请选择

OS / 操作系统

  • macOS
  • Windows
  • Linux
  • Others / 其他

Browser / 浏览器

  • Chrome
  • Edge
  • Firefox
  • Safari (Limited support / 有限支持)
  • IE (Nonsupport / 不支持)
  • Others / 其他
@2014guai 2014guai added the waiting for maintainer Triage or intervention needed from a maintainer. label Feb 26, 2025
@github-actions github-actions bot changed the title [Bug]: G6 v5.0.43在vue2项目中启动报错 [Bug]: G6 v5.0.43 is getting an error when starting in a vue2 project Feb 26, 2025
Copy link

这个错误是由于在 Vue 2 项目中使用 G6 v5.0.43 时,Webpack 没有正确配置以处理私有字段(例如 #matrix)导致的。私有字段是 JavaScript 的一种新特性,可能需要更新的 Babel 配置或 Webpack 加载器来支持。

以下是一些可能的解决方案:

  1. 更新 Babel 配置

    • 确保 Babel 配置中包含对私有字段的支持。你可以在 .babelrcbabel.config.js 中添加以下插件:
      {
        "plugins": ["@babel/plugin-proposal-class-properties", "@babel/plugin-proposal-private-methods"]
      }
  2. 更新 Webpack 配置

    • 确保 Webpack 配置中使用了 Babel 加载器来处理 JavaScript 文件。你可以在 webpack.config.js 中添加或更新 Babel 加载器的配置:
      module: {
        rules: [
          {
            test: /\.js$/,
            exclude: /node_modules/,
            use: {
              loader: 'babel-loader',
              options: {
                presets: ['@babel/preset-env'],
                plugins: ['@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-private-methods']
              }
            }
          }
        ]
      }
  3. 检查依赖版本

    • 确保所有相关依赖(如 Babel、Webpack、G6 等)都是最新版本,因为较新的版本可能已经修复了相关问题。

如果这些方法仍然无法解决问题,请告诉我,我会进一步帮助你。

🪧 Tips For further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for maintainer Triage or intervention needed from a maintainer.
Projects
None yet
Development

No branches or pull requests

1 participant