Skip to content
Advertisement

Node.js: fs.existsSync doesn’t work on Heroku

I have a Heroku app using Node.js and Express, and I want to determine whether or not a certain file exists. However, it seems like the file is never found. I have the following path:

JavaScript

The directory structure of my project looks like this:

JavaScript

I am doing something wrong here? Or is this a Heroku issue?

Advertisement

Answer

Ok, I needed to change pages/sims/${simName}.ejs to views/pages/sims/${simName}.ejs.

I had previously tried /views/pages/sims/${simName}.ejs, which didn’t work because of how the file paths work in Heroku.

I also added braces, as per the suggestion of @UserToday (although this wasn’t necessary).

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement