I tried to install node.js by NVM in Ubuntu 16.04 server by following this link. And I got:
root@instance-15s8fbzx:/opt# nodejs --version
v4.2.6
root@instance-15s8fbzx:/opt# npm --version
5.3.0
root@instance-15s8fbzx:/opt# node --version
v8.4.0
Then, we I run a mean-stack project by sudo npm start
, I got
class User {
^^^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
Then, I saw this link, I think maybe because the nodejs version is not correct. I have another server with v5.12.0
as the version of nodejs
, and the project worked well there.
Then, I tried to do
sudo npm install -g npm
sudo npm install -g n
sudo n stable
sudo ln -sf /usr/local/n/versions/node/8.4.0/bin/node /usr/bin/node
But the version of the nodejs is still 4.2.6
. Does anyone know how to upgrade its version to 5.12.0
?