Nodejs troubleshooting

I kept getting many errors in npm install

seems that the error comes from symlink not being able to work in vagrant
partial solution: run ‘$ sudo npm install –no-bin-links’
The reason you are getting errors is because you are in vagrant synced folder. If you go to a non synced folder the error will not occur. You can also change vagrant to accept symlink on shared/synced folder. Instructions at http://baligena.com/vagrant-miscellaneous/

Tried to run “$ npm run build” for use in browserify but got this error.

/usr/bin/env: node: No such file or directory
npm ERR! weird error 127
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! not ok code 0

The solution was to run
$ sudo apt-get install nodejs-legacy
source: https://laracasts.com/discuss/channels/general-discussion/npm-installer-with-gulp-weird-error-127

If you don’t have the latest version of npm errors may occur when installing packages
# check version in server. npm current version is shown in https://en.wikipedia.org/wiki/Npm_%28software%29
$ npm -v
# install latest version. you must run this twice I dont know why.
$ sudo npm install -g npm@latest