nodemjs
v0.1.16
Published
Run .mjs files from your command line, with all the tweaks from esmod-pmb.
Downloads
448
Readme
nodemjs
Run .mjs files from your command line, with all the tweaks from esmod-pmb.
Added features:
- Legacy-resolves module names passed with
-rif they would otherwise yield theERR_MODULE_RESOLUTION_LEGACYerror. - Pre-imports all modules listed in env var
NODEMJS_PRELOADand npm settingnodemjs-preload(see caveats below). Multiple module specs can be separated with spaces. They will be loaded even before the-rpre-imports.
⚠ Incompatible with node.js v20+! ⚠
… because the upstream esm module is no longer maintained.
See issue #2.
API
No.
CLI
$ nodemjs test/uc1st.mjs
uc1st: [ 'Using dummy input', 'Because there were', 'No CLI args' ]
$ ./test/uc1st.mjs foo bar qux
uc1st: [ 'Foo', 'Bar', 'Qux' ]Setup
npm install --global nodemjs- Make sure you have a node.js (compatible) binary available as the
nodejscommand. If you use sane package sources, you probably do. If you don't, just make a symlinknodejstonodeor whatever it's called on your system. (If you'd like to argue the supremacy of the more genericnodecommand name, file an issue, ideally after you've renamed the Node.js foundation to Node foundation.) As of 0.1.7, you can configure your favoritenodejsreplacement via theNODEJS_CMDenv var.
Known issues
Currently no support for setting
process.mainModule, see the upstream bug ticket.npm config caveat: The
nodemjs-preloadnpm setting is currently ignored if its value as a string is literallyundefined. If you want to pre-load a module with that name and nothing else, put it in twice, with a space between. See also: Duplicate pre-imports.Duplicate pre-imports:
nodemjscurrently does not check whether a module you're trying to pre-import had already been imported before. Usually node's module cache voids all non-first import attempts per module, so this won't matter — unless you use cache-busting modules, in which case you're on your own.REPL: The REPL isn't upgraded to ESM because
esmcurrently cannot expose its REPL in a clean and easy way.The
invokedAscontext property fornodemjsCliMaindoesn't work.Needs more/better tests and docs.
License
ISC
