1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

pm2でdeployしようとするとbash: npx: command not foundで失敗する

Posted at

原因

  • bash_profileにnvmの設定を記述していた
  • bash_profileは対話モードじゃないと読み込まれない
    参考
  • しょうがないので/usr/local以下のnvmとは関係ない古いnpmが呼ばれる

→npxコマンドが存在しない

現状

ecosystem.json

  "deploy" : {
    "production" : {
      "user" : "dev",
      "host" : "**********",
      "ref"  : "origin/master",
      "repo" : "**********",
      "path" : "/home/dev/www/",
      "post-deploy" : "npm install && npx sequelize db:migrate"
    }

対策

その1:nvmの設定をbash_profileではなくbashrcに記述する
その2:post-deployにsource ~/.bash_profileを追加する


"post-deploy" : "source ~/.bash_profile && npm install && npx sequelize db:migrate"

検索しても同じ状況の人が全然見つからなかったのでたどり着くのに時間がかかりました・・・。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?