【问题标题】:AWS CDK: AWS-ec2 SyntaxError: Unexpected token '.' after update nodeAWS CDK: AWS-ec2 SyntaxError: Unexpected token \'.\' after update node
【发布时间】:2022-12-02 10:05:10
【问题描述】:

I update NX and related versions. so now using node 14.15.0 instead of node 12.20.2

node version updated. so I update the aws-cdk packages. but now the following command is not working anymore. the issue is the optional chaining operator in aws-ec2.

npx env-cmd -f pipeline.json npx ts-node --project ./scripts/tsconfig.json ./apps/cloud-infrastructure/src/bin/pre-build.ts

I get the following error when I fire the above command.

node version 14.15.0. (tried in another version as well)

compiler options in ts configtsconfig.base.json

  "compileOnSave": false,
  "compilerOptions": {
    "rootDir": ".",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "module": "esnext",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom",
      "esnext.asynciterable"
    ],
    "skipLibCheck": true,
    "skipDefaultLibCheck": true
}
"files": [
    "./polyfills.localize.ts"
  ],
  "exclude": [
    "node_modules",
    "tmp"
  ]

ts config

{
  "extends": "../tsconfig.base.json",
  "compilerOptions": {
    "types": ["node", "jest"],
    "lib": ["ES6", "ES2017", "es2015", "ES2020.Promise"],
    "module": "CommonJS"
  },
  "include": ["**/*.ts"]
}

【问题讨论】:

  • What's your TS version?
  • 4.2.4 @Richard Dunn
  • What have you set as the target in ../tsconfig.base.json?
  • As I mentioned, that tsconfig isn't being used when compiling that JS. Also, that version of node doesn't appear to be the one you're using either as 14.15 should support the optional chaining operator. I don't use NX so can't help you much there, but I think it's probably not working the way you think it is.
  • I found "node" separately in the package.json and it's 12.x. so update it to 14.x and working fine

标签: javascript node.js amazon-ec2 aws-cdk


【解决方案1】:

As mentioned on this answer to a GitHub issue, you probably need to update Node from 12 (either to 14 or 16). The best way to do this is to update your package file, run npm update, then resolve dependency issues.

【讨论】:

    猜你喜欢
    • 2019-08-08
    • 1970-01-01
    • 2021-08-24
    • 2012-05-17
    • 2019-02-10
    • 2019-11-10
    • 2014-07-08
    • 2013-11-15
    • 2020-09-26
    相关资源
    最近更新 更多