I\'m trying to deploy a node app, but I\'m running into a problem with how my code is structure. The app is git inited at the top level and it looks like:
App (
Heroku requires a package.json
and a lockfile in the root of the repository or they will fail the deploy.
However you can set up a package.json
in the root of the repo which installs dependencies for the subdirectories and runs their related commands.
Using yarn for example, in your case you could put an empty yarn.lock
in the root and a package.json
like:
{
"name": "my-project",
"version": "0.1.0",
"private": true,
"scripts": {
"postinstall": "yarn --cwd server --production=false install",
"build": "yarn --cwd server serve"
}
}
The --production=false
ensures that devDependencies will be installed, which otherwise wouldn't happen since NODE_ENV
is set to production
in Heroku's environment.