This turned out to be the file path of the file that was the problem. When starting the server using node, the working directory is the same as the server.js file, so node.js manages to find the file.
When started using nohup or just starting forever, the working directory does not look the same as server.js.
I solved this by adding the __dirname global variable to the file name.
source share