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

130
Views
Cannot use import statement outside a module although type is module

I'm using ES6 style and want to be consistent of using import from ES6.

Here is my jest test file I'm setting up:

import Get from './Get'

test('Some test', async () => {
    expect(true).toBe(true)
})

And here is my Get file:

import cli from "commander";
import get from "./myHandler.js"

const GET = () => {
    // Doing some stuff here...
}

export default GET

I keep getting:

    C:\...\GET\get.test.js:2
    import Get from './Get';
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1773:14)

And I have already added "type": "module", in my package.json as suggested by this and others. What am I doing wrong here?

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!