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

Module not found: Can't resolve 'd3-drag' in Next.js #556

Open
karpinski1994 opened this issue Mar 9, 2023 · 0 comments
Open

Module not found: Can't resolve 'd3-drag' in Next.js #556

karpinski1994 opened this issue Mar 9, 2023 · 0 comments

Comments

@karpinski1994
Copy link

karpinski1994 commented Mar 9, 2023

Describe the bug
After installing the dependency and running in Next.js 13+ i received the following error:
Failed to compile
./node_modules/react-d3-graph/lib/components/graph/Graph.js:10:0
Module not found: Can't resolve 'd3-drag'

Import trace for requested module:
./node_modules/react-d3-graph/lib/index.js
./pages/graph-visualization.tsx

https://nextjs.org/docs/messages/module-not-found

To Reproduce
Steps to reproduce the behavior:

  1. Install react-d3-graph
  2. Implement any of graph examples from documentation
  3. run yarn dev / npm run dev
  4. See error

Expected behavior
Package working flawlessly

Screenshots
image

Environment:

  • MacOS Ventura 13.2.1 Apple M2
  • Chrome 111.0.5563.64 (Official Build) (arm64)
  • Node version 16.17.0
  • react-d3-graph version 2.6.0

After installing d3-drag as a peerDependency inside the package.json of the package (node_modules/react-d3-graph/package.json) the problem was solved
image

"peerDependencies": {
"d3": "^5.5.0",
"d3-drag": "^3.0.0",
"react": "^16.4.1"
},

I created a dummy quick fix, but not sure whether it is a good approach?
https://github.com/karpinski1994/react-d3-graph/pull/1

Edit:
After just reinstalling d3 to version 7.8.2 I'm having the following error:
image

Adding d3-drag to peerDependencies of the package also solves it upfront

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant