Unitech / Unitech/pm2

post deploy hook failed- bash: npm: command not found

Open
#5,393 3 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

What's going wrong?

When deploying to a remote machine using pm2 deploy server if fails on the post deploy hook where I am running the following

'post-deploy': `npm install && pm2 startOrRestart ecosystem.config.js --update-env --env development`,

Results in "

 ○ executing post-deploy `npm install && pm2 startOrRestart ecosystem.config.js --update-env --env development`
bash: npm: command not found

  post-deploy hook failed

Deploy failed
Deploy failed with exit code: 1

I can SSH into the machine and manually run the commands in the post-deploy hook and they work fine. It just doesn't work when deploying. This is one of 4 environments of essentially identical machines in the same ecosystem.config.js file, only this one has an issue. Not sure where to start.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the pm2 deploy entry point and the ecosystem.config.js post-deploy hook shown in the report. Compare the remote shell environment and PATH for the failing machine with the three working environments, then reproduce the hook through deployment rather than SSH. Done means the cause of the missing npm command is identified and the deployment behavior or required configuration is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.