10:21:17 PM: error: Uncaught (in promise) Error: Module not found "file:///PatientNextGen/apps/clinical-content/common/gql/redirect"

Local build is working fine but on deployment in netlify facing the below issue.

10:21:17 PM: Edge Functions bundling                                       
10:21:17 PM: ────────────────────────────────────────────────────────────────
10:21:17 PM: ​
10:21:17 PM: Packaging Edge Functions from netlify/edge-functions directory:
10:21:17 PM:  - redirect
10:21:17 PM: error: Uncaught (in promise) Error: Module not found "file:///PatientNextGen/apps/clinical-content/common/gql/redirect".
10:21:17 PM:       const ret = new Error(getStringFromWasm0(arg0, arg1));
10:21:17 PM:                   ^
10:21:17 PM:     at __wbg_new_d258248ed531ff54 (file:///opt/buildhome/node-deps/node_modules/@netlify/edge-bundler/deno/vendor/deno.land/x/eszip@v0.55.2/eszip_wasm.generated.js:443:19)
10:21:17 PM:     at <anonymous> (file:///opt/buildhome/node-deps/node_modules/@netlify/edge-bundler/deno/vendor/deno.land/x/eszip@v0.55.2/eszip_wasm_bg.wasm:1:41320)
10:21:17 PM:     at <anonymous> (file:///opt/buildhome/node-deps/node_modules/@netlify/edge-bundler/deno/vendor/deno.land/x/eszip@v0.55.2/eszip_wasm_bg.wasm:1:1967317)
10:21:17 PM:     at <anonymous> (file:///opt/buildhome/node-deps/node_modules/@netlify/edge-bundler/deno/vendor/deno.land/x/eszip@v0.55.2/eszip_wasm_bg.wasm:1:2501533)
10:21:17 PM:     at __wbg_adapter_40 (file:///opt/buildhome/node-deps/node_modules/@netlify/edge-bundler/deno/vendor/deno.land/x/eszip@v0.55.2/eszip_wasm.generated.js:240:8)
10:21:17 PM:     at real (file:///opt/buildhome/node-deps/node_modules/@netlify/edge-bundler/deno/vendor/deno.land/x/eszip@v0.55.2/eszip_wasm.generated.js:225:14)

Folder structure:

Hi @Ramji_R , the error is happening on the quoted lines below.

the path file:///PatientNextGen/apps/clinical-content/common/gql/redirect". will work locally but will not work on production.
The file should be located in your project and you have to specify a relative path to your project.

Thanks.

Can you provide a example I don’t know how to find the relative paths in netlify in the above case.

Hi @Ramji_R, relative paths is not specific to Netlify but mostly application development or operating system file management on servers via terminal consoles e.t.c.

So in terms of an example let’s assume you have your application in a folder called PatientNextGen.
If your main.ts is in the root of PatientNextGen, then the relative path to the redirect.ts file will be
./apps/clinical-content/common/gql/redirect.ts

If the redirect.ts is located elsewhere on your computer you can make a copy of it in your project folder PatientNextGen

So an example of importing the variables or functions from the module is below.

import { someFunction } from './apps/clinical-content/common/gql/redirect.ts';

// Use the imported function
someFunction();

Hope the above helps.

Thanks.

Thanks for your reply still the code can’t able to find the file.

I tried as you specified

import { redirectItems } from "./apps/clinical-content/common/gql/redirect.ts";

import { post } from "./apps/clinical-content/services/https";

Getting below error now

5:40:37 PM: Packaging Edge Functions from netlify/edge-functions directory:

5:40:37 PM: - redirect

5:40:38 PM: Failed during stage "building site": Build script returned non-zero exit code: 2

5:40:38 PM: error: Uncaught (in promise) Error: Error: Could not find file: file:///opt/build/repo/netlify/edge-functions/apps/clinical-content/common/gql/redirect.ts

Hey @Ramji_R,

Are you sure the path is correct? I don’t believe @clarnx’s answer was meant to be copied as it is (or if it was, it’s not correct). I assume @clarnx was merely suggesting you to check your relative imports and make sure the paths are correct, and what they provided was an example.

Your screenshot is a little cropped, so I don’t know if the apps directory is within PatientNextGen or not. If it is, your original import statement was correct, however, you might be affected by:

If that’s not it, please share your complete project structure.

1 Like

@hrishikesh This is my project structure. The edge-function should access the folder inside the apps folder.

In that case, the path should be:

../../apps/clinical-content/common/gql/redirect
1 Like