0.1.0 • Published 6 years ago

node-r_esm v0.1.0

Weekly downloads
6
License
ISC
Repository
github
Last release
6 years ago

node-r_esm

Little wrapper script to allow running your .mjs file via its shebang

The "esm" module has the nice invocation method of running an ES module file like this:

$ nodejs -r esm test/nospace.mjs
util.promisify? function

However, if you try to use that in a shebang line, you'll get an error like

$ ./test/nospace.mjs
/usr/bin/env: node -r esm: No such file or directory

… because the you can only pass one arg after the program name.

This package contains a small bash script that inserts the -r esm options, so you can write your shebang like this:

#!/usr/bin/env node-r_esm

and this run your module like this:

$ ./test/shebang.mjs
util.promisify? function

Caveats

  • This module doesn't (yet) care about whether the esm module is installed, or where. Your package will probably have to declare it as a dependency. The version used, and whether nodejs will find it, might even depend on the current working directory from which the shebang file is invoked.

 

License

ISC