NodeJS “Must use import to load ES Module”
问题 I'm trying to import myArr from hello.js into index.js . However I get an error of Error [ERR_REQUIRE_ESM]: Must use import to load ES Module hello.js export let myArr = ['hello', 'hi', 'hey']; index.js import { myArr } from './hello.js' console.log(myArr) Where am I going wrong? 回答1: The problem is that node does not currently support import and export natively yet. It is still experimental according to the docs. I recommend you use babel to compile your code and allow you to use import and