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

278
Views
SyntaxError: Cannot use import statement outside a module with shared package

I am currently working on building a shared node package between my NextJS app & Firebase Functions backend. Here is the current directory structure:

├── backend/
│   └── functions/
├── product/
└── shared/

Here is my index.ts that I export from my shared package:

import { SUPPORTED_WEBSITES } from "./websites/supportedWebsites";
import { getSupportedWebsite, addAffilateLink } from "./websites/utils";

export default { SUPPORTED_WEBSITES, getSupportedWebsite, addAffilateLink };

I then reference in firebase/functions:

import shared from "shared"

export const exampleFunc = functions.https.onCall(
   async (data, context) => {
      shared.getSupportedWebsite("amazon.com")
   }
)

I then run firebase emulators:start to try to test out exampleFunc and I get:

import { SUPPORTED_WEBSITES } from "./websites/supportedWebsites";
^^^^^^

SyntaxError: Cannot use import statement outside a module

I am currently symlinking shared to backend/functions via Lerna.

Please let me know if you have any ideas/need more clarification.

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

0

Update

I was able to fix this by compiling my shared/src files into commonjs files via tsc

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!