Niekes / d3-3d

d3-3d is a powerful JavaScript library designed for 3D visualizations, specifically tailored to work seamlessly with d3.js. This library enables the projection of 3D data onto web browsers, making it an essential tool for developers interested in creating immersive and dynamic visualizations.
BSD 3-Clause "New" or "Revised" License
357 stars 34 forks source link

Problem with index.js #28

Closed DanielNasseh closed 8 months ago

DanielNasseh commented 8 months ago

Dear Stefan,

great package. Got this error though: Any way to fix it? (locally if needed)

C:******\myapp\node_modules\d3-3d\index.js:5 export { default as _3d } from './src/3d.js'; ^^^^^^

SyntaxError: Unexpected token 'export' at internalCompileFunction (node:internal/vm:73:18) at wrapSafe (node:internal/modules/cjs/loader:1176:20) at Module._compile (node:internal/modules/cjs/loader:1218:27) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at ModuleWrap. (node:internal/modules/esm/translators:169:29) at ModuleJob.run (node:internal/modules/esm/module_job:194:25

Niekes commented 8 months ago

Which version do you use?

DanielNasseh commented 8 months ago

According to package.js

"type": "module",
"dependencies": {
    "d3": "^7.8.5",
    "d3-3d": "^0.1.3"

and if it is relevant:

"devDependencies": {
    "@types/d3": "^7.4.3",

This is my node version: v18.16.0

I imported it via npm and this is how i import it into my script: (svelte in this case)

import { _3d } from 'd3-3d';

Niekes commented 8 months ago

Given that your project is using ECMAScript modules ("type": "module" in your package.json) and you're running Node.js version 18, it should support ES6 import/export syntax.

However, the issue might be related to the fact that you are using an older version of the d3-3d library that might not be fully compatible with ES6 modules. The version you have (^0.1.3) is relatively old, and there might be compatibility issues.

I have tested it and everything works perfectly fine:

import { triangles3D } from 'd3-3d';

DanielNasseh commented 8 months ago

My apologies, i wasn't aware it was an old version. Strangely, "npm update" told me i am up to date: I had to use: "install d3-3d@latest" Now i got version 1.0.0 and everything works fine!

Thank you for helping me figuring it out!