node.jsexpressdeploymentbackendrender

Problems Deploying Node App With Render.com


I would like to post a simple stripe integration on render. I apologize in advance for my ignorance on the topic but, since I'm more front-end oriented, it's the first time I've attempted to do such a thing so I would like to ask you

  1. if the repository https://github.com/Luca-Liseros-Ferrari/stripe-example.git is ready to be published, if there is some error that can cause the deploy to fail or if some preliminary operation is required (in the server folder I also have an .env file with the stripe keys and I specified STATIC_DIR = "../client/")

  2. In render.com after clicking on "new" - "web service" and connecting the github repository and considering that from the terminal I start the server.js with the following commands:

cd server

node server.js

how should I fill in the "root directory", "build command" and "start command" fields since it's still not clear to me? Is the root directory the folder that contains the server.js file inside? In my case it would be for example "folderName/server" or simply "server"?

I tried to upload the repository to render but i get the following error message

Failed - Exited with status 1 while running your code.

It also tells me "error cannot find module express"

then I reinstalled express in server folder with npm install express and verified it was already installed. I therefore believe that there is a path error in the phase in which I create the web service.

error snippet

I hope I have provided enough data and I thank anyone who is willing to give me a hand in advance


Solution

  • I solved the problem. I had to specify in render.com in advanced the key - value pairs of my .env file

    I noticed it thanks to the Cyclic app which, after loading the repository, warned me that if the app doesn't work it could be because of that

    I hope it will help someone