When trying to run the passphrase example from the README in node, I get:
import { base64_variants, from_base64, from_string, to_base64, to_string } from "libsodium-wrappers-sumo";
^^^^^^^^^^^^^^^
SyntaxError: Named export 'base64_variants' not found. The requested module 'libsodium-wrappers-sumo' 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 'libsodium-wrappers-sumo';
const { base64_variants, from_base64, from_string, to_base64, to_string } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:214:5)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async loadESM (node:internal/process/esm_loader:34:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)
Node.js v21.1.0
My suspicion was that this was because I'm running this in a project set to "type": "module", but it happens even when I run it in a .mjs file without "type": "module".
When trying to run the passphrase example from the README in
node
, I get:My suspicion was that this was because I'm running this in a project set to
"type": "module"
, but it happens even when I run it in a.mjs
file without"type": "module"
.When I try to run it in
bun
, I get:I'm about to send a PR that includes one possible fix.