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

102
Views
Node import statement can't recognize ../ prefix

I am trying to use the ES Module import with a path like ../module.js and it gives me this error:

node:internal/errors:464
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 

Here is the structure of the folders:

.
├── module.js
├── index.js
├── folder
│   └── test.js

Also here is the import and export statements

//folder/test.js
import { test } from "../module"

//module.js
export async function test(data) {
    //Do Stuff then return data
}

Obviously, I have changed some file names and removed the function code. Please let me know if this is a problem.

Thank you!

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

0

In ECMAScript Modules, file extensions are mandatory according to the documentation, as well as directory indexes must be explicitly specified:

import { test } from "../module.js";
about 4 years ago · Juan Pablo Isaza Report

0

Try using require:

const { test } = require('../module.js')
about 4 years ago · Juan Pablo Isaza Report

0

module is already declared into nodejs, try changing the name of your file to something else.

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!