Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module

After added the index.pug file in the views folder and alter the code as shown in the video I got the following error message:

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /flashcards/node_modules/is-promise/index.js
require() of ES modules is not supported.
require() of /flashcards/node_modules/is-promise/index.js from /flashcards/node_modules/jstransformer/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename /flashcards/node_modules/is-promise/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /flashcards/node_modules/is-promise/package.json.

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1174:13)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/flashcards/node_modules/jstransformer/index.js:6:17)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)