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

254
Views
How to use package with js? Installed the package, but getting: “SyntaxError: Cannot use import statement outside a module”

This is my first time using js so bear with me (I’m an experienced python programmer).

How am I supposed to use this repo in js: https://github.com/omerdn1/otter.ai-api

I installed the package with npm and created the setup script (and updated it to fit my login info), but I’m getting a SyntaxError: SyntaxError: Cannot use import statement outside a module at the first line import OtterApi from 'otter.ai-api';.

I looked at the similar SO questions (1 and 2) and the solution seems to be adding ”type”: “module” to the package.json file. But 1) I’m not sure if they actually me “module” or its a specific module name 2) I tried this with both “module” and “OtterApi” and I’m still getting the SyntaxError.

I’m totally lost. Don’t know how modules work in js. Would greatly appreciate your help. :)

Edit: I replaced the import with the following instead: const OtterApi = require('otter.ai-api')

This seems to work as the initial error is no longer there. However, I’m now getting a separate SyntaxError (which is may be unrelated to the first error?): SyntaxError: await is only valid in async functions and the top level bodies of modules.

This is from the following code:

const OtterApi = require(‘otter.ai-api’);

const otterApi = new OtterApi({
  email: 'email@example.com', // Your otter.ai email
  password: 'abc123!#', // Your otter.ai password
});

await otterApi.init() // Performs login

The error happens at the last line.

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

0

I used the setup code, but I replaced the import with the following instead: const OtterApi = require('otter.ai-api').

Apparently, you can’t use ES Modules in Node without jumping through some hoops (or maybe using the latest version?). So, the above resolves that issue.

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!