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

356
Views
Node Error: Cannot use import statement outside a module even though I am not

I have tried adding "type: module" to package.json but that does not work.

I have tried renaming the file extension to .mjs and .cjs but that does not work either.

I have switched my imports/require between the following:

import fetch from 'node-fetch';

import _metascraper from 'metascraper';
import url from 'metascraper-url';
import description from 'metascraper-description';
const metascraper = _metascraper([title(),description()]);

To using require:

const metascraper = require('metascraper')([
  require('metascraper-description')(),
  require('metascraper-title')()
])

The errors are either:

  • Cannot use import statement outside a module
  • Rename to .cjs or add type: module to package.json
  • Cannot find module
about 4 years ago · Juan Pablo Isaza
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!