LoginSignup
1
0

More than 5 years have passed since last update.

Babelなどの追加モジュールなしでnodeコマンドたけでサクッと import/export を動かす

Posted at

:writing_hand: ES Mmodules

  • .mjs 拡張子にする
  • --experimental-modules オプションを指定する
version
node -v
# v8.11.2
export.mjs
export default () => "🙋";
import.mjs
import f from "./export";
console.log(f());
ESMフラグを付けて実行する
node --experimental-modules import.mjs
# (node:509) ExperimentalWarning: The ESM module loader is experimental.
# 🙋

:moyai: 「...ちょろっとスクリプト書く時ももうrequireしなくてええやん」

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0