publish = “build”
I have an app with several netlify functions that all use a db-helper.js file which runs fine locally using ntl dev and Sveltekit 1.0.
After running npm build and ntl deploy it is telling me it cant find the $lib/db-helper.js file., hence the header of this topic.
In case it was the “$lib”, I moved the file and changed all references to $lib to ‘…/…/src/constants/db-helper’ and now when I run npm run build and ntl deploy and click “Projects”, which calls the first netlify function, it crashes with the attached error, referring to dotenv, which IS installed and I reinstalled and reran and it gives the same message.
I move the db_helper.js file into the lib folder but give it a path ‘…/…/src/lib/db-helper’. Run build again. ntl deploy. Click on “projects” and it now gives a 502 error, but doesnt provide any detail on the error :
GET https://63cf4406a0f50b62db2240c2--peppy-rolypoly-dd9af0.netlify.app/.netlify/functions/getProjects 502
I moved the helper file into root of src, rebuilt, redeployed. This time it failed to deploy with error:
“$ ntl deploy
» Error: request to https://api.netlify.com/api/v1/sites?filter=all failed, reason: getaddrinfo ENOTFOUND api.netlify.com”
Moved it to root of application. Failed to deploy - same error as above.
Four different locations. Three different errors! It seems to matter where this file is located but I have not found the right location.
Is there a specific location for netlify function helper files or is there a way in the netlify.toml file to tell Netlify that this helper file is to be used with the netlify functions?
My netlify functions all import a “client” (Mongodb) from db-helper. In the Netlify functions it creates and connection to the client. It all works locally and it all works in Svelte. But now I am using Sveltekit.
I will try another function tomorrow and see if I can figure out what is happening.
I am using adapter-netlify in svelte.config.js and when i run npm run build it shows “Using @sveltejs/adapter-netlify” with a tick (correct) done. The rest of the app, not using netlify functions is all working.
I would appreciate it if you do not close this request (again) until a resolution is found. Thank you.