Why does node, npm, and yarn return 'command not found' after successful build?

Issue

A user's build has successfully built and released, but at runtime, the app is unable to find node, npm and/or yarn.

You may see something like this:

~ $ npm -v
bash: npm: command not found
~ $ node -v
bash: node: command not found
~ $ yarn -v
bash: yarn: command not found

Resolution

There is likely a script that is running at build-time that is overwriting the Node binaries.

From the root of the app directory, run:

grep -iRl "PATH" .

This will output all the files that has PATH in them.

Note: If you are running this from a Heroku dyno, you can ignore any files in the .heroku directory - that comes from the compile step of the build.

If any files have reassigned $PATH, make sure that they look something like this:

export PATH=/new/binary:/other/new/bin:$PATH

If the :$PATH is missing from any assignment to PATH, the binaries from the Heroku build (including node, yarn and npm) will not be available at runtime.

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support