#I am facing error when deploying on vercel

19 messages · Page 1 of 1 (latest)

primal kayak
#

Error: ENOENT: no such file or directory, open '/vercel/path0/.next/server/chunks/DB/20151116/GeoLite2-City.mmdb'

at m.openSync (/vercel/path0/.next/server/chunks/217.js:1:94726)
at d.openSync (/vercel/path0/.next/server/chunks/217.js:1:87115)
at i.init (/vercel/path0/.next/server/chunks/217.js:1:96623)
at new i (/vercel/path0/.next/server/chunks/217.js:1:96578)
at 27641 (/vercel/path0/.next/server/chunks/217.js:1:97083)
at t (/vercel/path0/.next/server/webpack-runtime.js:1:143)
at 48730 (/vercel/path0/.next/server/app/api/auth/forget-password/route.js:1:5841)
at t (/vercel/path0/.next/server/webpack-runtime.js:1:143) {

errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/vercel/path0/.next/server/chunks/DB/20151116/GeoLite2-City.mmdb'
}

raven ravenBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

hazy flintBOT
# primal kayak Error: ENOENT: no such file or directory, open '/vercel/path0/.next/server/chunk...
Please add more information to your question

Your question currently does not have sufficient information for people to be able to help. Please add more information to help us help you, for example: relevant code snippets, a reproduction repository, and/or more detailed error messages. See more info on how to ask a good question in https://discord.com/channels/752553802359505017/1138338531983491154 and #welcome message.

primal kayak
#

@heady harness

My route seems correct but idk why it throwing error in production for file not found

#

I have no clue about where the error is comming in forget-password route

import { NextRequest, NextResponse } from "next/server";
import User from "@/models/User";
import connectDB from "@/db";
import bcryptjs from 'bcryptjs';
import { forgotPasswordValidation } from "@/validations/User";
import { createTokenPayload, signAccessToken, signInfoToken } from "@/utils/auth";
import { ClientDetailsType, getClientIPInfo, IPInfoType } from "@/utils/UserTracking";
import { v4 as uuidv4 } from 'uuid';
import SessionModel from "@/models/Session";


export async function POST(req: NextRequest) {
    try {

        await connectDB();

        const data = await req.json();

        const { email, otp, password, confirmPassword } = data;

        const { error } = forgotPasswordValidation.validate({ email, otp, password, confirmPassword });

        if (error) return NextResponse.json({ success: false, message: error.details[0].message.replace(/['"]+/g, '') });

        const findUser = await User.findOne({ email });

        if (!findUser) return NextResponse.json({ success: false, message: 'Account Not Found' });

        som more code ....
a
    } catch (error: any) {

        console.log("Error in Resetting User Password (Server) => ", error.message)

        return NextResponse.json({ success: false, message: "oopss ! Something went wrong..." });
    }
}
heady harness
#

are you using fs or reading any file?

primal kayak
#

in the backend no I just have an auth system yet

heady harness
#

Are upi readomg any file, because if I'm right, its attempting to read GeoLite2-City.rmdb

primal kayak
#

alright then i think some packages code , i am using these to track the user based on ip etc for session

import { NextRequest } from "next/server";
import DeviceDetector from 'device-detector-js';
import UAParser from 'ua-parser-js';

// @ts-ignore
import satelize from "satelize";
#

and yes 1 thing i remember is that satelize doesn't have ts type so i tried to use ignore to get rid of that

#

these are the pakcages that is in use in auth/forget-password cuz i am creating a new session there

#

got it

the problem is indeed with pakakage as now i installed
https://www.npmjs.com/package/geoip-lite

and error file name change to geoip-country.dat

heady harness
#

you can try to use this in vercel.json, to that file path. I'm unsure if it would work:

    "functions": {
        "funcName/*": {
            "includeFiles": "path/to/file"
        }
    }
primal kayak
#

i am unsure about that file to, cuz i don't have to provide that file , package imports and it should have come with pakcage

actaully these thing was working fine on my node js app that i deploy on beanstalk so i am clueless now about the file , let see at least now i know who is creating an error i'll try to find other packages or ways

function actually return me country code lat- long and timezone etc

// Define an interface for the IP Info response
export interface IPInfoType {
    country: string;
    timezone: string;
    country_code: string;
    lat_long: string;
}

// Function to get client IP info based on IP address
export const getClientIPInfo = async (ip: string): Promise<IPInfoType | null> => {
    try {
        // Get geolocation information from geoip-lite
        const geo = geoip.lookup(ip);

        // Declare the variables to store user details with initial values
        let country = "Unknown";
        let timezone = "Unknown";
        let country_code = "Unknown";
        let lat_long = "Unknown";

        if (geo) {
            country = geo.country || "Unknown";
            timezone = geo.timezone || "Unknown"; // Get timezone directly from geo
            country_code = geo.country || "Unknown"; // Assuming country code is the same as country
            lat_long = geo.ll ? `${geo.ll[0]}, ${geo.ll[1]}` : "Unknown"; // Format lat and long
        }

        // Return the populated IP info object
        return { country, timezone, country_code, lat_long };

    } catch (error) {
        console.error('Error in getClientIPInfo (clientIPInfo.js) =>', (error as Error).message);
        return null;
    }
};
#

i try to find any other if possible to find these thing without pakcage

hazy flintBOT
# primal kayak i am unsure about that file to, cuz i don't have to provide that file , package ...
Please use code blocks

When sharing code or error messages, please use code blocks.
You can create a code block by wrapping your code in three backticks (`), like this: ```
code here

You can also specify the language in the code block (e.g. `ts`, `js`) to enable syntax highlighting:  ```ts
export default function Page(){}

Link a Gist to upload entire files: https://gist.github.com/
Link a Code Sandbox to share runnable examples: https://codesandbox.io/s
Link a Code Sandbox to an existing GitHub repo: https://codesandbox.io/s/github/<username>/<reponame>

heady harness
#

Summary:

  • The issue was caused due to the fact that a package was reading a file
  • That file needs to be added in vercel.json
#

Mark solution please if the issue is resolved