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 import d3-geo in node with typescript #261
Comments
@sardounis Did you solve this issue? |
downgrading to v2.0.1 worked for me |
More people with this problem here yanivam/react-svg-worldmap#135 |
any updates on this? |
ok my mistake.. I didn't import it as namespace :) // index.ts
import * as d3Geo from 'd3-geo'
// compiled index.js
const d3Geo = require('d3-geo') |
ok the esmodule import via |
this works for me:
|
yeah but dynamic imports aren't that nice.. so I'll stick to the 2.x.x for now :) |
It seems I have an issue of importing the library using nodejs 14 and typescript.
I have used @types/d3-geo as well.
Though I am getting the error:
An unexpected error occurred Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/antonissardounis/Projects/beat/bhs-cf/functions_new/functions/node_modules/d3-geo/src/index.js\nrequire() of ES modules is not supported.\nrequire() of /Users/antonissardounis/Projects/beat/bhs-cf/functions_new/functions/node_modules/d3-geo/src/index.js from /Users/antonissardounis/Projects/beat/bhs-cf/functions_new/functions/lib/utils/Geo/Geo.js is an ES module file as it is a .js file whose nearest parent package.json contains \"type\": \"module\" which defines all .js files in that package scope as ES modules.\nInstead rename index.js to end in .cjs, change the requiring code to use import(), or remove \"type\": \"module\" from /Users/antonissardounis/Projects/beat/bhs-cf/functions_new/functions/node_modules/d3-geo/package.json.\n\n at new NodeError (internal/errors.js:322:7)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1102:13)\n at Module.load (internal/modules/cjs/loader.js:950:32)\n at Function.Module._load (internal/modules/cjs/loader.js:790:12)\n at Module.require (internal/modules/cjs/loader.js:974:19)\n at require (internal/modules/cjs/helpers.js:101:18)\n at /Users/antonissardounis/Projects/beat/bhs-cf/functions_new/functions/lib/utils/Geo/Geo.js:33:75\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at async Geo.init (/Users/antonissardounis/Projects/beat/bhs-cf/functions_new/functions/lib/utils/Geo/Geo.js:33:27)\n at async Geo.AreCoordinatesInsideGeofence (/Users/antonissardounis/Projects/beat/bhs-cf/functions_new/functions/lib/utils/Geo/Geo.js:39:9) {\n code: 'ERR_REQUIRE_ESM'\n}"}
it seems there is an open issue at stack overflow as well: link
The text was updated successfully, but these errors were encountered: