*.DEFAULT不是构造函数
我知道这个问题有很多话题,但是我读了很多,但没有找到任何答案。
我尝试通过我的nodejs项目(NEST)中的NPM使用第三方。 但是,当它编译时,我有*。默认值不是构造函数
错误。
当我进入node_modules中的源时,我会看到错误。
const web3_1 = require("web3");
[...]
const getClient = async (options) => {
const { url } = options;
return new web3_1.default(url);
};
如果我在此处删除默认值,它像魅力一样工作,但这不是我控制的东西...
我将eSmoduleInterop
true放在我的tsconfig.json中,但这是不起作用的。
这是我的tsconfig文件
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": "./",
"incremental": true,
"strictNullChecks": true,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false,
"esModuleInterop": true,
"module": "CommonJS",
"target": "ES2018",
"declaration": true,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "./dist",
"rootDir": "./src",
"skipLibCheck": true
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"**/*.spec.ts"
]
}
我缺少什么?
I know there is plenty of topic around this question but I read a lot and I didn't found any answer.
I try to use a 3rd party through NPM in my nodeJS project (nest).
But when it compiles, I have the *.default is not a constructor
error.
When I go into the source in the node_modules, I see the error.
const web3_1 = require("web3");
[...]
const getClient = async (options) => {
const { url } = options;
return new web3_1.default(url);
};
If I remove the default in here, it's working like a charm, but this is not something I control ...
I put the esModuleInterop
to true in my tsconfig.json but that's not working.
Here is my tsconfig file
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": "./",
"incremental": true,
"strictNullChecks": true,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false,
"esModuleInterop": true,
"module": "CommonJS",
"target": "ES2018",
"declaration": true,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "./dist",
"rootDir": "./src",
"skipLibCheck": true
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"**/*.spec.ts"
]
}
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据他们的文档和 and 他们的源代码您不应该使用<代码>默认值。正义
,你应该很好。 看起来他们可能会陷入困境LL需要告诉打字条以忽略它
According to their docs and their source code you shouldn't need to use
default
. JustAnd you should be good. Looks like they may have their types messed up and you'll need to tell Typescript to ignore it