Centos 7.4 pm2 automatic deployment of node failed.-bash: pm2: command not found

Screenshot cannot be uploaded under mac. What the heck

enter the command in Tencent Cloud server to get the result

whereis pm2


pm2: /usr/bin/pm2 /usr/local/node-v6/bin/pm2


{
    "apps": [{
        "name": "music",
        "script": "server.js",
        "env": {
            "COMMON_VARIABLE": "true"
        },
       "env_production": {
           "NODE_ENV": "production"
       }
    }],
    "deploy": {
        "production": {
            "user": "root",
            "host": ["115.159.109.124"],
            "ref": "origin/master",
            "repo": "git@gitee.com:landluck/server.git",
            "path": "/home/ice/production",
            "ssh_options": "StrictHostKeyChecking=no",
            "post-deploy" : "npm install && pm2 startOrRestart ecosystem.json --env production",
            "pre-deploy-local": "echo "Deploy Done"",
            "env": {
                "NODE_ENV": "production"
            }
        }
    }
}
--> Deploying to production environment
--> on host 115.159.109.124
   deploying origin/master
   executing pre-deploy-local
Deploy Done
   hook pre-deploy
   fetching updates
   full fetch
Fetching origin
   resetting HEAD to origin/master
HEAD is now at 9c3f5df pm2 config
   executing post-deploy `export NODE_ENV=production && npm install && pm2 startOrRestart ecosystem.json --env production`
npm WARN enoent ENOENT: no such file or directory, open "/home/ice/production/source/package.json"
npm WARN source No description
npm WARN source No repository field.
npm WARN source No README data
npm WARN source No license field.
bash: pm2: command not found

  post-deploy hook failed

Deploy failed
Mar.01,2021

should be a problem of finding the command path. I encountered the same problem, which I solved in the following way:
sudo ln-s "$NVM_DIR/versions/node/v11.8.0/bin/pm2" / usr/local/bin/pm2 "
where" $NVM_DIR/versions/node/v11.8.0/bin/pm2 "is the path I got from running whereis pm2

Menu