Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

395
Vistas
Vercel Node Serverless fails to import ES6 module (vercel dev locally works fine)

I get this error when accessing an API endpoint in a Vercel deployment of a React app with a top level api/ folder containing serverless endpoints. Interestingly, this API endpoint works fine locally using vercel dev. Even more interestingly, a similar API endpoint in the same API folder which also uses ES6 module imports works fine.

[POST] /api/checkout
20:49:23:62
2021-02-20T04:49:23.818Z    undefined   ERROR   /var/task/api/checkout.js:1
import { firebaseAdmin, stripe } from "./_firebase_stripe";
^^^^^^
SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:979:16)
    at Module._compile (internal/modules/cjs/loader.js:1027:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at /var/task/___vc_launcher.js:26:28
    at Object.<anonymous> (/var/task/___vc_launcher.js:74:7)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
RequestId: 0e27de3f-fdd1-401a-a5e2-030327a15a31 Error: Runtime exited with error: exit status 1
Runtime.ExitError

This is the code which fails on the server once deployed but works fine locally.

import { firebaseAdmin, stripe } from "./_firebase_stripe";
import { getConfig } from "./_config";
import {
  verifiedUser,
  getCustomerCheckoutDetails,
  readyToGo,
} from "./_helpers";
export default async function Checkout(req, res) {
  const { url } = getConfig();
  let sessionId;

This is the content of api/hello.js which works fine both locally and on deployed version when accessing /api/hello.

import { firebaseAdmin } from "./_firebase_stripe";
import { getConfig } from "./_config";
export default function (_req, res) {
  const version = firebaseAdmin.SDK_VERSION;
  return res.send({ ...getConfig(), version });
}
over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda