• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

225
Views
SyntaxError: no se puede usar la declaración de importación fuera de un módulo con paquete compartido

Actualmente estoy trabajando en la creación de un paquete de nodos shared entre mi aplicación NextJS y el backend de Firebase Functions. Aquí está la estructura de directorios actual:

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

Aquí está mi index.ts que exporto desde mi paquete shared :

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

Luego hago referencia en firebase/functions :

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

Luego firebase emulators:start a intentar probar exampleFunc y obtengo:

 import { SUPPORTED_WEBSITES } from "./websites/supportedWebsites"; ^^^^^^ SyntaxError: Cannot use import statement outside a module

Actualmente estoy shared enlaces simbólicos con backend/functions a través de Lerna .

Por favor, hágamelo saber si tiene alguna idea o necesita más aclaraciones.

almost 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Actualizar

Pude solucionar esto compilando mis archivos shared/src en archivos commonjs a través de tsc

almost 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error