Use nvm in on a production server

Today I was putting up a personal project on a VPS to let friends try it out and thought I would use nvm because the project is using the latest unstable version of node.js. I was also using PM2 to keep the node application alive but when i restarted the server node was not in use. After visiting google i found an article about how to make nvm start node on server restart. The code below copies the current node to a shared folder but it needs to run each time you change node version:

 n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local 

It worked well and as the project was using an unstable version of node I ran in to problem with PM2 but thanks to nvm i easily down graded node from 0.11.12 to 0.11.9.

Leave a Reply

Your email address will not be published. Required fields are marked *