d3 / d3-force

Force-directed graph layout using velocity Verlet integration.
https://d3js.org/d3-force
ISC License
1.82k stars 377 forks source link

Importing to NestJs causes module import error #210

Closed bwmirek closed 2 years ago

bwmirek commented 2 years ago

Hi!, when I'm trying to import d3 force to default nestjs application the following error appears:

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: [path to local project]\node_modules\d3-force\src\index.js
require() of ES modules is not supported.

Import in code looks like this:

import { forceSimulation } from 'd3-force';
// or
import * as d3 from 'd3-force';
// or
import d3 from 'd3-force';

You can reproduce error by cloning this minimal repository: https://github.com/bwmirek/nestjs-d3-force-import-bug Run following commands:

yarn install
yarn start