Skip to content

Deployment: Fix npm command issue #300

Closed

Description

@vprashrex

Is your feature request related to a problem?
The production release v0.6.1 failed because the npm command was not found in the SSM deploy command, leading to the app still serving the previous version v0.5.0. This prevents new deployments from going live.

Describe the solution you'd like

  • Use the remote command from deploy-staging.yml.
  • Set ROOT_USER from the existing USER secret in the AWS_ENV environment.
  • Export HOME=/home/$ROOT_USER and load NVM from that user's home.
  • Run sudo -iu $ROOT_USER pm2 restart.
  • Cut a new release (v0.6.2) after merging.
Original issue

Describe the bug
The v0.6.1 production release failed again in "Wait for SSM command to finish", this time with:

.../_script.sh: line 1: npm: command not found
failed to run commands: exit status 127

Root cause

  • fix(workflows): Fix production release workflow #299 fixed the earlier $HOME not set error (Deployment: Fix $HOME issue #298) by setting HOME=/root and keeping the deploy running as root.
  • With that, git fetch and git checkout succeed, but root has no npm on its PATH. On the production host, node is installed through NVM under the deploy user (/home/<user>/.nvm), not system-wide.
  • The app also runs in the deploy user's pm2. So even with npm found, a root pm2 restart would not find the app.
  • Before chore(deployment): Improve build process #292, production loaded NVM from the deploy user's home and ran sudo -iu <user> pm2 restart. deploy-staging.yml still does this and deploys fine.

Impact

  • Production is still serving v0.5.0. v0.6.0 and v0.6.1 are not live.
  • On the server, the repo is now checked out at 7c29ec6 (v0.6.1), but .next is still the old build and pm2 was not restarted.

To Reproduce

  1. Push a release tag (e.g. v0.6.1).
  2. "Deploy Kaapi to EC2 Production" fails at "Wait for SSM command to finish" with npm: command not found.

Expected behavior
The release tag deploys to production: checkout, npm ci, build, and pm2 restart all succeed.

Fix
Use the same remote command as deploy-staging.yml. Set ROOT_USER from the existing USER secret in the AWS_ENV environment, then export HOME=/home/$ROOT_USER, load NVM from that user's home, and run sudo -iu $ROOT_USER pm2 restart. After merging, cut a new release (v0.6.2). A tag runs the workflow file from its own commit, so re-running v0.6.1 won't pick up the fix.

Activity

  1. self-assigned this
    on Oct 30, 2026
  2. changed the title [-]Production deploy fails: npm not found in SSM deploy command[/-] [+]Deployment: Fix npm command issue[/+] on Oct 30, 2026
  3. added theissue type on Oct 30, 2026
  4. github-actions commented on Oct 30, 2026

    @github-actions

    🎉 This issue has been resolved in version 0.6.2-main.1 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions