Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

688
Views
HOW TO FIx code : 'ERR_REQUIRE_ESM' const { nanoid } = require("nanoid");

how to fix it , I'm doing App chat . Sorry if the language is difficult to read, I'm Thai.

PS C:\Users\ADMIN\Desktop\chat\server> node server.js
C:\Users\ADMIN\Desktop\chat\server\server.js:4
const { nanoid } = require("nanoid");
               ^
[ERR_REQUIRE_ESM]: require() of ES Module 
C:\Users\ADMIN\Desktop\chat\server\node_modules\nanoid\index.js from 
at Object.<anonymous> (C:\Users\ADMIN\Desktop\chat\server\server.js:4:20) {
code: 'ERR_REQUIRE_ESM'



{
"name": "chat",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},

"keywords": [], "author": "", "license": "ISC", "dependencies": { "express": "^4.18.1", "nanoid": "^4.0.0", "socket.io": "^4.5.1" } }

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This means the library you're trying to require cannot be imported using the require syntax.

I think the version of the nanoid you're using needs to be imported using import

You could try downgrading nanoid or switching to the import keyword.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!