0
    [root@xx.xx.xx.xx xxxx]# n
   installed : v14.8.0 to /usr/local/bin/node
      active : v10.21.0 at /bin/node

Installed node version 14.8.0 using n. Not sure how 10.21.0 was installed. Cannot delete or switch versions. I am using pm2 process manager and need the versions switched i.e dont want to run n run v14.8.0 server.js i would rather change the active version globally, so that running pm2 start would not need to specify a specific version. Please help.

Cola
  • 2,097
  • 4
  • 24
  • 30
  • You have two versions of node installed, and could either delete the old one, or modify your path. Try "n doctor" for clues, and see https://stackoverflow.com/questions/65657802/node-version-will-not-update-using-n/65658906 – shadowspawn Jan 14 '21 at 23:09

1 Answers1

0

First, you can explicitly select /usr/local/bin/node by creating a file like

/usr/local/bin/node server.js

Make sure to rename it to something ending with .sh Then to run it with pm2 you can do pm2 run yourfilename.sh

Second, you can use a shebang line in server.js, so the first line must be

#!/usr/local/bin/node

And you can run your script the way you were doing it before

Raymond
  • 396
  • 4
  • 21