NodeJS 要求client-dynamodb在节点版本18.13.0上产生语法错误(与uuid相关)

sdnqo3pr  于 2023-03-12  发布在  Node.js
关注(0)|答案(1)|浏览(117)

我的快捷应用程序中的下面一行

const ddbClient = require("@aws-sdk/client-dynamodb");

在节点v14.15.0上运行正常,但升级到v18.13.0后,会产生以下错误:

/mnt/e/CODING/nzgk_series/2/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:3541
    ClientRequestToken: input.ClientRequestToken ?? (0, uuid_1.v4)(),
                                                  ^

SyntaxError: Unexpected token ?
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/mnt/e/CODING/nzgk_series/2/node_modules/@aws-sdk/client-dynamodb/dist-cjs/commands/BatchExecuteStatementCommand.js:8:23)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

我使用NVM在两个版本之间跳转,添加和删除了这一行,并确认是它导致了这个问题。
我的包裹

{
  "name": "2",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "start": "nodemon app.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@aws-sdk/client-dynamodb": "^3.245.0",
    "@aws-sdk/util-dynamodb": "^3.245.0",
    "body-parser": "^1.20.1",
    "dotenv": "^16.0.3",
    "ejs": "^3.1.8",
    "express": "^4.18.2",
    "express-ejs-layouts": "^2.5.1",
    "socket.io": "^4.5.4",
    "uuid": "^9.0.0"
  }
}

任何帮助都将不胜感激。

p3rjfoxz

p3rjfoxz1#

这似乎是“@aws-sdk/client-dynamodb”的一个bug。尝试安装"@aws-sdk/client-dynamodb": "3.165.0"。这个版本的“@aws-sdk/client-dynamodb”没有使用空合并操作符“??"。因此,它不会给予你这个错误。我很惊讶更多的人没有这个问题。

相关问题