Run ES6 code in Bash terminal with Bash heredoc
问题 ES5 code can be run easily with Bash heredoc in terminal: node <<HEREDOC var fs = require("fs"); ... HEREDOC But ES6 code doesn't run, even with the correct --experimental-modules flag: node --experimental-modules <<HEREDOC import fs from "fs"; ... HEREDOC The error shown is: (node:4130) ExperimentalWarning: The ESM module loader is experimental. [stdin]:1 import fs from "fs"; ^^ SyntaxError: Unexpected identifier at new Script (vm.js:83:7) at createScript (vm.js:267:10) at Proxy