post deploy hook failed- bash: npm: command not found
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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