I am trying to import local modules but I get an error
Current versus Expected behavior
Here's the error:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/api/openai' imported from /var/task/api/routes/aiRoutes.js at finalizeResolution (node:internal/modules/esm/resolve:269:11) at moduleResolve (node:internal/modules/esm/resolve:937:10) at moduleResolveWithNodePath (node:internal/modules/esm/resolve:1173:14) at defaultResolve (node:internal/modules/esm/resolve:1216:79) at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:540:12) at ModuleLoader.resolve (node:internal/modules/esm/loader:509:25) at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:239:38) at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:96:40) at link (node:internal/modules/esm/module_job:95:36) { code: 'ERR_MODULE_NOT_FOUND', url: 'file:///var/task/api/openai'}Node.js process exited with exit status: 1. The logs above can help with debugging the issue.INIT_REPORT Init Duration: 240.76 ms Phase: invoke Status: error Error Type: Runtime.ExitErrorI would expect it to act normal and import the dang module
Code, configuration, and steps that reproduce this issue
Here's the code it doesn't like:
import { setupAIRoutes } from './routes/aiRoutes.js';import { setupLicenseRoutes } from './routes/licenseRoutes.js';Here's the vercel.json file (I tried adding the imports to the bundle it didn't help):
{ "rewrites": [ { "source": "/api/(.*)", "destination": "/api" } ], "redirects": [ { "source": "/", "destination": "/api", "permanent": false } ], "functions": { "api/index.js": { "includeFiles": "api/**" } }}Here's package.json
{ "type": "module", "engines": { "node": "20.x" }, "scripts": { "start": "vercel dev", "deploy": "vercel" }, "dependencies": { "@ai-sdk/openai": "^0.0.58", "@hono/node-server": "^1.12.2", "ai": "^3.3.34", "hono": "^4.4.2", "openai": "^4.59.0", "zod": "^3.23.8" }, "devDependencies": { "vercel": "^32.4.1" }}Project information
Deployment URL: https://vercel.com/geoidesics-projects/actor-studio-openai/DWAzrWceD272QMM6Jjra3reFsiPZEnvironment (local, preview, production): productionProject Framework: HonoBuild Settings: Framework Preset: Hono (https://vercel.com/templates/hono/hono-on-vercel) Build Command (if not default): vercel --prod Output Directory (if not default): Install Command (if not default): Node/Runtime Version: 20.xPackage Manager: yarnRelevant Packages: see package.json above