首页 > 解决方案 > Redhat nodeJS 是否支持异步?

问题描述

我有一个在 Windows 和 Ubuntu 中运行良好的应用程序。但是当我在其中部署Redhat系统然后启动时,有很多错误如下:

.../../lib/services/utils.service.js:11
async getData(dir, subName) {
^^^^^^^
SyntaxError: Unexpected identifier
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Function._load (.../node_modules/@pm2/io/build/main/metrics/httpMetrics.js:172:43)
at require (internal/module.js:20:19)
at Object.<anonymous> (/../lib/apis/healthCheck-controller/healthCheck.controller.js:13:14)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)

我试图删除异步,错误消失并显示下一个类似的错误。但是,我的代码中有很多异步,替换所有这些很糟糕

Redhat 系统是
Linux 版本 3.10.0-514.el7.x86_64 (mockbuild@x86-039.build.eng.bos.redhat.com) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC ) )

nodeJS 版本是 v11.1.0

标签: node.jsasynchronousredhat

解决方案


这是我的错,它在“/bin”中使用了较低的nodeJS版本位置,而不是我安装的“/usr/local/bin”版本。


推荐阅读