You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to import this library with the native support for ESM that's available in Node.js 12, 14, and 16 I'm running into the following problem:
import { isPointInPolygon } from 'geolib';
^^^^^^^^^^^^^^^^
SyntaxError: Named export 'isPointInPolygon' not found. The requested module 'geolib' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'geolib';
const { isPointInPolygon } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:179:5)
at async Loader.import (node:internal/modules/esm/loader:178:24)
at async Object.loadESM (node:internal/process/esm_loader:68:5)
at async handleMainPromise (node:internal/modules/run_main:63:12)
According to the readme it seems like this should work:
I think that the problem is that the package.json is missing the exports key which describes how the module should be loaded by the native Node.js ESM.
When trying to import this library with the native support for ESM that's available in Node.js 12, 14, and 16 I'm running into the following problem:
According to the readme it seems like this should work:
I think that the problem is that the package.json is missing the
exports
key which describes how the module should be loaded by the native Node.js ESM.This is documented here: https://nodejs.org/api/packages.html#packages_package_entry_points
Basically, I think that something like this should be added:
I will try this and submit a PR if it works 🚀
The text was updated successfully, but these errors were encountered: