user25093 user25093 - 15 days ago 5
Node.js Question

Node.js Express Server doesn't work on a different server, but works on my machine

When I run my node.js server on my machine, it works perfectly fine. However, when I ssh into a machine I got from digital ocean, it throws this error. I used flightplan to move my files to the machine.

deploy@myserver:~/node-app/bin$ node www

/home/deploy/node-app-1479873242669/routes/index.js:76
[newValue]: {
^
SyntaxError: Unexpected token [
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/deploy/node-app-1479873242669/app.js:36:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)


This is the code concerning the error:

if (isNaN(value)) {
newValue = 0;
console.log("queuer val " + newValue);
fbRef.update({
[newValue]: {
[UID]: ID
}
});
}


And like I said, this works perfectly fine on my machine. Thanks!

Answer

Update node to latest version :

wget -qO- https://deb.nodesource.com/setup_6.x | sudo bash -
sudo apt-get -y install nodejs

Should work after that.