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

Cannot find module '*/node_modules/graphology-layout-forceatlas2/worker' #67

Open
totase opened this issue May 14, 2024 · 2 comments
Open
Labels
bug Something isn't working

Comments

@totase
Copy link

totase commented May 14, 2024

I use react-sigma with vite, but when I run tests I get the following error in the console and the tests fail:

Error: Cannot find module '*/node_modules/graphology-layout-forceatlas2/worker' imported from */node_modules/@react-sigma/layout-forceatlas2/lib/react-sigma_layout-forceatlas2.esm.min.js
Did you mean to import graphology-layout-forceatlas2/worker.js?

Note that the application runs as expected, and I have no issue building the project. See list of dependencies below:

    "@react-sigma/core": "^4.0.2",
    "@react-sigma/layout-forceatlas2": "^4.0.2",
    "@sigma/edge-curve": "^3.0.0-beta.7",
    "classnames": "^2.5.1",
    "graphology": "^0.25.4",
    "graphology-types": "^0.24.7",
    "react": "^18.3.0",
    "sigma": "^3.0.0-beta.18",

    "vite": "^5.0.8",
    "vitest": "^1.2.1"

Operating System: Ubuntu 20.04.6 LTS

If I navigate to the module package it complains about (*/node_modules/@react-sigma/layout-forceatlas2/lib/react-sigma_layout-forceatlas2.esm.min.js) and manually change the import from import e from"graphology-layout-forceatlas2/worker"; to import e from"graphology-layout-forceatlas2/worker.js";, the tests run as expected. Is there any way to fix this within the package?

@totase totase added the bug Something isn't working label May 14, 2024
@sim51
Copy link
Owner

sim51 commented May 30, 2024

I'm not sure it's an issue with the package, due to the fact that you need to add the extension.
What version of graphology-layout-forceatlas2 do you use ?
Can you share your vite config file ?

@MylesWritesCode
Copy link

Unsure of vite's config, but I'm using webpack and I was able to get around this by using an alias e.g.

const config = {
  resolve: {
      alias: {
        'graphology-layout-forceatlas2/worker': 'graphology-layout-forceatlas2/worker.js', // added this here
      },
    },
  // ...rest of config
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants