Can't attach module
abrikos opened this issue · comments
My minter.js:
import {generateWallet} from 'minterjs-wallet'; const wallet = generateWallet();
Run
#nodejs --experimental-modules minter.mjs
Result:
SyntaxError: The requested module 'minterjs-wallet' does not provide an export named 'generateWallet'
at ModuleJob._instantiate (internal/modules/esm/module_job.js:80:21)
Run
#babel-node minter.mjs --presets es2015,stage-2
Result:
(function (exports, require, module, __filename, __dirname) { import bip39 from 'bip39';
^^^^^ (bip39)
SyntaxError: Unexpected identifier
at new Script (vm.js:79:7)
There is right way to run that?
Sorry for late response.
I think --experimental-modules
will not work, as minterjs files don't have .mjs
extension.
Babel approach fails, because it doesn't transpile minterjs-utils
from node_modules
This command should make it work:
babel-node --ignore '/node_modules/(?!minterjs-util)' --presets env index.js
Also minterjs-wallet@3.0.0
released and it has commonjs build which should work with node.js
without additional configuration