服务器上使用node运行项目使用的是ES5的strict模式
1、strict模式下 let const 不能使用
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/www/deltaning.com/index.js:3:14)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
2、for (var [key, value] of map) {}不能使用
遍历Map( )对象要使用forEach方法
比如
map.forEach(function (value, key, map) {
console.log(key, value)
})在服务器上使用for...of会报错
for (var [key, value] of temp.path) {
^
SyntaxError: Unexpected token [
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/www/deltaning.com/index.js:3:14)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
3、使node服务在后台运行以及关闭后台服务的方法
只要在命令末尾加上&符号就表示该服务在后台运行
[root@izffy43yi81886z deltaning.com]# node ./index.js &想要关闭后台服务
jobs查看后台正在运行的服务
[root@izffy43yi81886z deltaning.com]# jobs
[1]+ Running node ./index.js &
ps 查看后台服务[root@izffy43yi81886z deltaning.com]# ps
PID TTY TIME CMD
18797 pts/0 00:00:00 bash
19482 pts/0 00:00:00 node
19494 pts/0 00:00:00 ps
关闭服务(kill %PID)
[root@izffy43yi81886z deltaning.com]# kill 19482