Tek*_*cer 7 node.js typescript tsc
longYarn作为其他模块的依赖项安装。它安装“umd”版本,这显然是一个 CommonJS 模块。
我收到以下错误:
node_modules/long/umd/index.d.ts:1:18 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead.
import Long from "../index.js";
Run Code Online (Sandbox Code Playgroud)
显然,我不能只按照指示更新文件。
有没有办法强制打字稿编译器不使用该umd版本?
包.json
{
"name": "<project>",
"version": "1.0.0",
"engines": {
"node": "20.x.x"
},
"main": "index.js",
"repository": "<repo>",
"author": "<author>",
"license": "MIT",
"scripts": {
"dev": "nodemon",
"build": "tsc && tsc-alias",
...
},
"devDependencies": {
"nodemon": "^3.0.1",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.7",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.3.0-dev.20230920"
},
"dependencies": {
...
}
}
Run Code Online (Sandbox Code Playgroud)
tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"module": "NodeNext",
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"baseUrl": "src",
"outDir": "./build",
"sourceMap": true,
"noImplicitAny": true,
"types": ["./elevenlabs-api.d.ts"],
"paths": {
"@/*": ["./*"],
...
}
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
Run Code Online (Sandbox Code Playgroud)
我尝试long@4.0.0显式安装(非 UMD 版本)long@5.2.3有一个umd子文件夹。中的基本包node_modules是正确的,但依赖于它的所有其他包都会使用node_modules破坏版本创建自己的文件夹。
我尝试过使用有效的顶级依赖项的相同版本。long结果相同:无论如何都安装了破坏版本。
| 归档时间: |
|
| 查看次数: |
523 次 |
| 最近记录: |