Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

Heroku cannot tell that your app is a Node.js app

ErrorNo 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.

  • Applies to Heroku CLI, heroku/nodejs buildpack, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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-app
  2. 2Match what you see, then jump to its fix

    1. 1git 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. 2heroku 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

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.json

2Fix

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 main

3Verify

The build log now starts with the Node.js buildpack instead of the detection error.

heroku logs --tail -a my-app

Confirmed by devcenter.heroku.com

Did this fix it?

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-app

2Fix

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 main

3Verify

The listing shows heroku/nodejs and the build starts.

heroku buildpacks -a my-app

Confirmed by devcenter.heroku.com

Did this fix it?

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

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.