Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nehir's avatar
Level 1

Unable to Access HTML Files

I am trying to create a module for sending emails using nodemailer. To do so, I want to read HTML templates from a folder. However, when I supply the path to the HTML file to ReadFileSync, I am unable to access the file when I npm install the module in my project. My understanding is that this is because file paths are relative to the working directory, not the file using the path. So I tried to use __dirname Which I then found out is undefined using Node modules. So then I tried using import.meta.url which worked when using vite dev and vite preview but not when I deploy them to firebase as import.meta.url becomes undefined.

I am using Sveltekit and Firebase

0 likes
2 replies
nehir's avatar
Level 1

I am trying to create a module for sending emails using nodemailer. To do so, I want to read HTML templates from a folder. However, when I supply the path to the HTML file to ReadFileSync, I am unable to access the file when I npm install the module in my project. My understanding is that this is because file paths are relative to the working directory, not the file using the path. So I tried to use __dirname Which I then found out is undefined using Node modules. So then I tried using import.meta.url which worked when using vite dev and vite preview but not when I deploy them to firebase as import.meta.url becomes undefined. https://19216801.onl/ I am using Sveltekit and Firebase.

I got this,..

Please or to participate in this conversation.