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
Seems that the .node extension trips up Node when running a file as a module (ESM).
To repro on node 12, 14, 16, 17:
mkdir example
cd example
npm init -y
touch example.mjs
in example.mjs:
import {Nodehun} from 'nodehun'
console.log(Nodehun)
Then running node example.js yields:
$ node example.mjs
node:internal/errors:464
ErrorCaptureStackTrace(err);
^
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".node"for /Users/tilde/.../example/node_modules/nodehun/build/Release/Nodehun.node
at new NodeError (node:internal/errors:371:5)
at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:87:11)
at defaultGetFormat (node:internal/modules/esm/get_format:102:38)
at defaultLoad (node:internal/modules/esm/load:21:14)
at ESMLoader.load (node:internal/modules/esm/loader:359:26)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:280:58)
at new ModuleJob (node:internal/modules/esm/module_job:66:26)
at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:297:17)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:261:34)
at async ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:81:21) {
code: 'ERR_UNKNOWN_FILE_EXTENSION'
}
Node.js v17.4.0
The text was updated successfully, but these errors were encountered:
Seems that the
.node
extension trips up Node when running a file as a module (ESM).To repro on node 12, 14, 16, 17:
mkdir example cd example npm init -y touch example.mjs
in
example.mjs
:Then running
node example.js
yields:The text was updated successfully, but these errors were encountered: