Node.js · Junior · Question 15 of 75
What is required in an ES module import of a local file that is optional in require()?
- 1The
awaitkeyword - ✓Correct answer: The file extension, e.g.
import x from "./utils.js" - 3A leading
@in the path
Explanation
ESM in Node.js follows URL rules, so relative imports must include the extension. require("./utils") can guess .js, .json or index.js.