Time Remaining3:00
easyDependenciesNode.js

The ESM/CJS clash

A developer asked an AI assistant to add a small utility package to a Node.js script. The suggested import statement matches the package's README exactly, but running the script throws immediately.

generateId.js
// package.json has no "type" field, so this file is treated as CommonJS
import { nanoid } from 'nanoid';

console.log(nanoid());

Why does this script crash immediately with a SyntaxError?

The file is being run as CommonJS — no "type": "module" in package.json — but import syntax is only valid in ES modules, so Node rejects it before the script can even run.
nanoid is a TypeScript-only package and cannot be imported from plain JavaScript.
console.log cannot be called with a function result directly; it must be assigned to a variable first.
nanoid() must be awaited even though it doesn't return a promise.