I have a netlify function with 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.
Where should such a file be located so that Netlify deploys it correctly?
We can’t comment on why that’s happening without seeing your repo or your folder structure. The only reason why this would happen is when you don’t have a file in the functions folder (as per your netlify.toml
Hi Sam, thank you for your response. I am confused by your comment on not creating multiple threads. I created three threads on three different issues, same site. Should I create 1 thread on all issues? I dont think that would be a great idea as it could get confusing talking about three issues in one thread and I couldnt get all issues into one header. I felt it would be better to to have the three threads on three different issues which would probably be helpful to others trying to tackle a specific issue. But if thats your requirement then I will add all issues here. You closed another issue without commenting because I created multiple threads?!
Issue 1: Netlify helper function not found in deployment using Sveltekit.
Regarding this specific issue, I have a netlify/functions folder and I have several netlify functions, all of which call a db-helper.js file which for convenience I put into Sveltekit’s provided lib folder. Convenient because instead of having to type out the path when importing the file eg import {createClient" from ‘…/…/src/lib/db-helper’ you can just use from ‘$lib/db-helper’. But when I use $lib netlify has problems in the deploy.
My netlify.toml file is:
[build]
command=“svelte-kit build”
publish = “build”
I do not specify the netlify functions folder because i dont need to since I am using the default netlify/functions folder. I cant imagine that the rest of my folder structure is of any use to you but if you want it I can provide it. I do not have a repo and it would mean creating one from scratch with pieces of the application.
I will reply again on the other two issues, in this thread.
Issue 2: Will Netlify-cli be deprecated soon? That was a reference to the fact that there are/were a growing number of deprecated packages used in netlify-cli, but I have upgraded twice in two days and there are fewer, so you can mark that as closed. Oops, you already did!
Issue 3: What is going on with Netlify-adapter and build. (or something to that effect).
I am using Sveltekit 1.0, netlify-cli 12.5.0 , win32-x64 node-v18.12.1 and I am using Netlify-adapter.
I run ntl dev and my application runs fine locally.
I run ntl deploy and get prompted to create a build. I run npm run build. It creates a “build” folder (called “build”). (Sveltekit is creating a .svelte-kit folder now).
I run ntl deploy and the provided draft website url runs fine.
However, I now try continue locally with ntl dev and my app is a total mess, navigation not working, css not working, just a mess of some pages thrown on the screen.
I DELETE the build folder and run ntl dev and my application is now running fine again.
I saw another similar thread which was unresolved with a request for a repo. Would a video work in place of a repo. To create a repo is work because you basically have to start from scratch and just provide the minimal number of files in order to recreate the problem.
Let me know if you want me to create a video or a repo.
Thanks. No, this is a different issue to the svelte-routing/Svelte. That issue was not resolved.
Now, I am working with Sveltekit which has its own routing.
I did not previously try ntl deploy --build. I just tried this. It gives me an ERROR Invalid command: build … “build.command” failed, Error message “Command failed with exit code 1: svelte-kit build”.
I show above my netlify.toml file.
If I run npm run build it shows Vite v4.0.4 building SSR bundle for production, shows a bunch of .svelte-kit/output/server files and a bunch of .svelte-kit/output/client files. Ends with checkmark done. So no errors.
How do I answer your question “Could you confirm if Svelte is being detected as your framework inside the CLI?” ? I see nothing to confirm it is or is not.
I am very confused now with the directions provided in this support forum. I put up THREE separate requests based on a Sveltekit codebase. All were marked as CLOSED by Sam and I was told not to submit multiple threads. They are the same Svelekit codebase but different issues. So now I put all the issues together into this single thread and I get a response on one issue only?
This turned out to have nothing to do with the location of the helper functions for netlify but instead the environment variables. Instead of importing dotenv, I added env variables to netlify site and that worked!