Node.js 12+ has new command-line option --input-type to run script inside Bash heredoc. However, it doesn't seem to be able to find Node.js modules installed in ./node_modules
Here's how I install a module:
cd test
npm i moment
And run Node.js with script in heredoc:
cd test
#this works
node --experimental-modules --input-type module <<<"import fs from 'fs'"
#this doesn't
node --experimental-modules --input-type module <<<"import moment from 'moment'"
Even installing moment with global option -g, it still yields ERR_MODULE_NOT_FOUND error. Any solutions?