我正在使用 typescript 作为 Nodejs 服务器。我正在使用
sequelize
进行 MySQL 数据库连接。
如果我运行
nodemon server.ts
,一切都会正常。但是 npx tsc
抛出以下错误:
node_modules/sequelize/types/transaction.d.ts:121:13 - error TS2395: Individual declarations in merged declaration 'LOCK' must be all exported or all local.
121 export enum LOCK {
~~~~
node_modules/sequelize/types/transaction.d.ts:134:11 - error TS2395: Individual declarations in merged declaration 'LOCK' must be all exported or all local.
134 interface LOCK {
~~~~
Found 2 errors in the same file, starting at: node_modules/sequelize/types/transaction.d.ts:121
在包json文件中:
"sequelize": "^6.32.1",
"sequelize-typescript": "^2.1.5",
"typescript": "^5.1.6",
"@types/node": "^20.5.2",
"@types/sequelize": "^4.28.15",
我的
"type": "commonjs"
文件中有 package.json
。节点版本v14.21.3
没有任何痕迹可调试。我已经仔细检查过版本,没有不匹配的地方。
请指出我缺少的内容,或者是否有任何以前的问题我无法找到。
此错误是由于您的 TypeScript 版本与您使用的 Sequelize 版本不匹配造成的。
Sequelize 6.32.1
正在使用 TypeScript ^4.5.4
。
在我的项目中安装相同的 TypeScript 版本为我解决了这个问题:
npm install --save-dev typescript@^4.5.4
npx tsc