[英]Why doesn't node.js server work on my subdomain (using cloudflare on WHM server)?
[英]Node.js Express Server doesn't work on a different server, but works on my machine
當我在機器上運行node.js服務器時,它運行正常。 但是,當我將自己從數字海洋中拿到機器中時,它會拋出此錯誤。 我使用Flightplan將文件移動到計算機上。
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)
這是有關錯誤的代碼:
if (isNaN(value)) {
newValue = 0;
console.log("queuer val " + newValue);
fbRef.update({
[newValue]: {
[UID]: ID
}
});
}
就像我說的那樣,這在我的機器上可以正常工作。 謝謝!
將節點更新為最新版本:
wget -qO- https://deb.nodesource.com/setup_6.x | sudo bash -
sudo apt-get -y install nodejs
在那之后應該工作。
使用計算鍵創建對象是ES2015 Standard (ES6)的一部分。 請參閱對象初始化程序規范 。
在您的情況下,原始JavaScript不支持此功能:
[newValue]: {
[UID]: ID
}
因此,您的node -v
可能會高於v6.0.0
,但其他服務器將是舊版本。 更新節點版本或將babel-node
與預設一起使用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.