Closed abulka closed 2 years ago
You are very right. As I explain here, PR #254 introduced a regression problem that prevented Node.js from correctly identifying the type of module to load (ESM or CommonJS)
The problem has been fixed in release 3.0.20 and is now available on NPM.
This highlights the need for plaftorm-targeted unit tests going forward. Thanks a lot for reporting.
Description
import {WebMidi} from "webmidi"
is not working in node, despite what the official documentation says. I get an error aboutNamed export 'WebMidi' not found
.To reproduce, simply create a new directory
npm i webmidi
"type": "module",
to thepackage.json
main.js
withrun with
node main.js
and I getmy package.json is
Environment:
v16.13.1
Seems also to be related to issues #89 and #82
v16.14.2
on a different machine, an M1 mac - same problem.v12.22.9
- same problem.main.mjs
does not change the error.Details Add any other information, context or details that could help track down the problem.
Trying an alternative import syntax
instead changes the error to:
Taking node's advice and changing the import to
fails with the same
Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.... SyntaxError: Unexpected token 'export'
error.Discussion
Interestingly, the simple module example given in #252
supposedly works for @djipco - but I can't get past the import problem mentioned above.