Node.js · Junior · Question 15 of 75

What is required in an ES module import of a local file that is optional in require()?

Explanation

ESM in Node.js follows URL rules, so relative imports must include the extension. require("./utils") can guess .js, .json or index.js.

Further reading

Problem with a question

Node.js · Junior · question 15

Test yourself

Take the Node.js · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz