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

Add package.json type as module #49

Merged
merged 1 commit into from
Jan 29, 2022
Merged

Conversation

pschroen
Copy link
Contributor

For the ES6 import syntax to work from Node.js.

Without that an error is thrown from command-line:

import { oimo } from 'oimophysics';
         ^^^^
SyntaxError: Named export 'oimo' not found. The requested module 'oimophysics' 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 'oimophysics';
const { oimo } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:127:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:191:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:337:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12)

Node.js v17.4.0

For reference:
https://nodejs.org/docs/latest/api/esm.html#esm_enabling

@saharan
Copy link
Owner

saharan commented Jan 29, 2022

Thank you for the fix!

@saharan saharan merged commit 297090f into saharan:develop Jan 29, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants