Next.js Discord

Discord Forum

Help with using geo-tz library with nextjs hosted on vercel

Unanswered
Northern Wheatear posted this in #help-forum
Open in Discord
Northern WheatearOP
I'm trying to use geo-tz library for getting timezone from coordinates. This works well in both dev and production build locally. But in vercel it doesn't and shows this error

Error: ENOENT: no such file or directory, open '/var/task/node_modules/.pnpm/geo-tz@8.1.2/node_modules/geo-tz/data/timezones-1970.geojson.geo.dat'
    at g (.next/server/app/[version]/stepbox/open/route.js:1:3331) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/var/task/node_modules/.pnpm/geo-tz@8.1.2/node_modules/geo-tz/data/timezones-1970.geojson.geo.dat'
}


This is the next config that I used
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  serverExternalPackages: ["geo-tz"],
};

export default nextConfig;


If anyone knows how to fix this or have worked earlier with this library please let me know. Thanks!

1 Reply

Britannia Petite
This lib seems to not be intended for serverless environments like Vercel as it depends on reading data from the disk, see https://github.com/evansiroky/node-geo-tz/?tab=readme-ov-file#performance