【发布时间】:2021-10-13 17:26:09
【问题描述】:
当我尝试使用 mvn test 对我的 CDK Java 项目运行单元测试时,我收到一个错误 Node v8.9.1 has reached end-of-life and is not supported.。
但 Node v12.22.1 是我当前的版本,我在运行 Maven 之前检查了它。
node --version
v12.22.1
mvn test
....
奇怪的是,如果我通过 IntelliJ GUI 运行 Maven,它就可以工作。
如果这很重要,我已将我的节点版本设置为 nvm。我在 Mac 上。
我需要设置一些环境变量吗? CDK 如何确定使用哪个节点?
有什么想法吗?
谢谢!
完整输出:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! !!
!! Node v8.9.1 has reached end-of-life and is not supported. !!
!! You may to encounter runtime issues, and should switch to a supported release. !!
!! !!
!! As of the current release, supported versions of node are: !!
!! - ^12.7.0 !!
!! - ^14.5.0 !!
!! - ^16.3.0 !!
!! !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
(node:14462) Warning: process.on(SIGPROF) is reserved while debugging
/private/var/folders/nr/dkx1p38s24nb7fx_qgcxggcm0000gn/T/jsii-java-runtime8055040669944096944/lib/program.js:467
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:599:28)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
【问题讨论】:
-
我的 /usr/local/bin/node 是 8.9.1 版。一定是在用那个。 Surefire 插件可能会派生一个新的 JVM,并且它不能遵守 nvm 设置。我忘了说的一件事是
cdk deploy和cdk synth在本地工作;失败仅在于运行测试。因此,这强化了新 JVM 启动方式的理论。
标签: aws-cdk