1
我已经搜索了这个问题的堆栈溢出,但我仍然不清楚为什么发生这种情况/如何解决。TS2403:随后的变量声明必须具有相同的类型。 NPM安装后
我想节点分型在我的打字稿的项目,所以我进入这个命令:
npm install @types/node --save
这就造成:
c:/xyz/node_modules/@types/node/index.d.ts(89,13)
error TS2403: Subsequent variable declarations must have the same type.
Variable 'require' must be of type 'Require', but here has type 'NodeRequire'.
我的机器有节点7.0.3版 安装的类型是为版本+ @类型/节点@ 7.0.28
如果我删除卸载typings我的项目编译没有问题。
它看起来好像每个错误信息的打字内容都不正确!修复它是凌乱的。有小费吗?
好像NodeRequire(接口)需要支持Require.js的被绕过?
这是TSConfig文件:
{
"compilerOptions": {
"module": "amd",
"moduleResolution": "node",
"target": "es5",
"noImplicitAny": false,
"jsx": "react",
"sourceMap": false,
"baseUrl": ".",
"paths": {
"OfficeFabric/*": [
"node_modules/office-ui-fabric-react/lib-amd/*"
]
}
}
}
我试图排除建议以下没有工作。 Github说,如果模块分辨率是NODE,那么排除不会起作用。
您是否曾尝试在您的'tsconfig.json'中添加'“exclude”:[“node_modules”]'? – Saravana