Error: ENOENT: no such file or directory,
Unanswered
Black Mouth Cur posted this in #help-forum
Black Mouth CurOP
I stumbled upon this error on production build on vercel:
so im using this package https://www.npmjs.com/package/idn-area-data.
on api route,
im using pages folder on this project.
on dev it return the data, but on vercel i got that error. anyone know how to solve the error?
[Error: ENOENT: no such file or directory, open '/var/task/node_modules/idn-area-data/data/regencies.csv'] {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/var/task/node_modules/idn-area-data/data/regencies.csv'
}so im using this package https://www.npmjs.com/package/idn-area-data.
on api route,
import { type Regency } from "idn-area-data";
import type { NextApiRequest, NextApiResponse } from "next";
type ResponseData = {
data: Regency[];
};
export default async function handler(
req: NextApiRequest,
res: NextApiResponse<ResponseData>
) {
const { getRegencies } = await import("idn-area-data");
const regencies = await getRegencies({ transform: true });
res.status(200).json({ data: regencies });
}im using pages folder on this project.
on dev it return the data, but on vercel i got that error. anyone know how to solve the error?
2 Replies
Black Mouth CurOP
yes, there was no problem when i ran npm install, the api is work on local dev, but doesnt work on vercel production build.