npm

Need private packages and team management tools?Check out npm Orgs. »

node-r_esm

0.1.0 • Public • Published

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

Keywords

install

npm i node-r_esm

Downloadsweekly downloads

3

version

0.1.0

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability