Course lesson
Set the Node.js Project to ECMAScript Modules (ESM)
Node.js projects have two ways that you can import and export code into different files. This is through CommonJS (CJS) and ECMAScript modules (ESM).
- Duration
- 2 min
- Access
- Included
- Transcript
- Retained from source evidence
Node.js projects have two ways that you can import and export code into different files. This is through CommonJS (CJS) and ECMAScript modules (ESM).
CommonJS is Node's default way to import modules but because I like to have my Node.js code similar to my frontend code, we will use ESM for this project.
To do so we will set a project type in our package.json.