How do I tell heroku that my server.js and package.json are inside a folder?

Viewed 1193

Currently my file structure looks like this

enter image description here

As you can see, my server and package files are inside the backend folder. The project-replays folder is the frontend folder.

As expected, when I do heroku local on my root folder, it tells me that it cant find a package.json that should be placed on the root folder. Is there a way to tell heroku to look for the package.json inside the backend folder?

1 Answers

You'll need to add a package.json to root, even if it's just for running scripts. Detecting a package.json is how the Node buildpack detects a Node app too, so it's a minimum requirement to run Node on Heroku.

You'll want to add something like this:

"scripts": {
  "start": "node backend/server.js"
}

heroku local will by default use the npm start script at root.

Related