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

376
Views
Node.js: cannot find module ... imported from

This makes no sense. The file exists, but i just cannot import it. My code has a lot of imports in the same format, but only this one is failing.

The error

[The code] (bin/hyp.js)

#!/usr/bin/env node


process.title = "hyp"

import subcommand from 'subcommand'
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'

import * as hyper from '../lib/hyper/index.js'

import info from '../lib/commands/info.js'
import create from '../lib/commands/create.js'
import seed from '../lib/commands/seed.js'
import unseed from '../lib/commands/unseed.js'
import beam from '../lib/commands/beam.js'
import alias from '../lib/commmands/alias.js'

The folder structure:

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

0

According to Node.js Documentation

You must either change the filename extension of the module to be .mjs, so change alias.js to be alias.mjs (and change the import as appropriate)

OR, you can add this config option to package.json:

"type": "module"

This will allow you to use include instead of require syntax.

about 4 years ago · Juan Pablo Isaza Report

0

If your importation alias is really a node modules you just have to import it like this "import alias from 'alias' ".

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!