How can an ES6 module be run as a script in Node?
When I try this shebang I get an error:
#!/usr/bin/env node --experimental-modules
/usr/bin/env: ‘node --experimental-modules’: No such file or directory
If I use this shebang it has syntax errors (of course):
#!/usr/bin/env node
SyntaxError: Unexpected token import
The work around I'm using is to use a shell script to call the module:
#!/usr/bin/env sh
BASEDIR=$( dirname "$0" )
node --experimental-modules $BASEDIR/script.mjs "$@"
Is it possible to get this working without a second file?