Heroku cannot tell that your app is a Node.js app
No default language could be detected for this app.Short answer
Heroku picks a buildpack by looking for a marker file, and for Node.js that is package.json in the root of the pushed repository. The error means Heroku did not find it there, or the app has no buildpack set. Push the folder that holds package.json, then set heroku/nodejs if needed.
Fix it fast
1Find out which cause you have
Check that package.json is tracked by git at the top level of the repository you push, and list the buildpacks the app has.
git ls-files package.json heroku buildpacks -a my-app2Match what you see, then jump to its fix
- 1
git ls-files package.json prints nothing, or the Node.js code lives in a subfolder such as server/ or backend/package.json is not in the root of the pushed repositoryFix - 2
heroku buildpacks shows nothing, or lists a language that your code does not useNo buildpack is set, or the wrong one is set, on the Heroku appFix
- 1
What does the error look like?
No default language could be detected for this app.git push heroku main is rejected during the build step
Cause 1 of 2
package.json is not in the root of the pushed repository
1Check
The Node.js buildpack is used when the app has a package.json in its root directory. A file in a subfolder, or one that is untracked or ignored, does not count.
git rev-parse --show-toplevel
git status --short package.json2Fix
Push a repository whose root holds package.json. Commit the file if it is untracked. For an app in a subfolder, make that folder the repository root, or deploy the subfolder to Heroku on its own.
git add package.json
git commit -m "Add package.json"
git push heroku main3Verify
The build log now starts with the Node.js buildpack instead of the detection error.
heroku logs --tail -a my-appConfirmed by devcenter.heroku.com
Cause 2 of 2
No buildpack is set, or the wrong one is set, on the Heroku app
1Check
Detection runs again on the next push when no buildpack is set. If the app has a different buildpack set, that one is used and detection for Node.js never happens.
heroku buildpacks -a my-app2Fix
Set the Node.js buildpack by hand. The app must still contain package.json, because the buildpack's own detection must pass.
heroku buildpacks:clear -a my-app
heroku buildpacks:set heroku/nodejs -a my-app
git push heroku main3Verify
The listing shows heroku/nodejs and the build starts.
heroku buildpacks -a my-appConfirmed by devcenter.heroku.com
How do I stop it coming back?
- Keep package.json in the repository root, or deploy each subfolder as its own repository.
- Commit package.json and the lockfile together, and check git status before you push.
- Add a start script or a Procfile so Heroku knows how to run the web process after the build.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
git push heroku fails while building a Node.js app
Error: Unknown error installing "22" of node
When a Heroku Node.js build fails, the push is rejected and the reason sits in the remote lines just above the failure.
5 causes, each with a fixServers
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fixServers
Azure App Service on Linux restarts the container and the site never starts
The container restarts again and again and the site returns an application error
App Service sends a warmup request to the container and restarts it if no HTTP answer comes back in time.
5 causes, each with a fixServers
bcrypt_lib.node: invalid ELF header inside a Docker container
Error: /app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
bcrypt is a compiled addon, so the file in node_modules only runs on the operating system it was installed on.
3 causes, each with a fixServers
AWS CDK cannot find module '@aws-cdk/aws-ec2' (or another @aws-cdk/aws-* package)
Cannot find module '@aws-cdk/aws-ec2'
CDK v2 no longer ships one npm package per service.
3 causes, each with a fixServers
cdk deploy fails in a GitLab job with spawnSync docker ENOENT
code: 'ENOENT'
ENOENT means the operating system found no docker program to run.
3 causes, each with a fix