我已经成功地使用AspNetCore 2.2,SignalR和TypeScript前端创建了一个小型应用程序。该捆绑包是通过WebPack创建的。
我想尝试的是启用MessagePack协议插件。但是,关于如何安装的the docs似乎不够准确。尽管命令行编译(npm run build)看起来很好,但是当我启动应用程序进行调试时,由于TypeScript代码中的某些内容缺失,它无法编译:
错误TS2688内部版本:找不到“节点”的类型定义文件。 C:\ ... \ node_modules @ aspnet \ signalr-protocol-msgpack \ dist \ esm \ MessagePackHubProtocol.d.ts 1
错误TS2580内部版本:找不到名称“缓冲区”。您需要安装吗 节点的类型定义?尝试
npm i @types/node
,然后添加node
到tsconfig中的types字段。 C:\ ... \ node_modules @ aspnet \ signalr-protocol-msgpack \ dist \ esm \ MessagePackHubProtocol.d.ts 16
顺便说一句,如果我遵循该提示,由于我的代码中出现了“ setTimeout”,事情将会变得更糟。基本上,似乎“节点” setTimeout会覆盖“窗口”的设置,并且它们的签名不匹配。
这是package.json(没有提示的补丁程序):
{
"version": "1.0.0",
"name": "asp.net",
"private": true,
"devDependencies": {
"del": "2.2.0",
"@types/jquery": "^3.3.29",
"ts-loader": "^5.3.3",
"typescript": "^3.2.2",
"webpack": "^4.28.3",
"webpack-cli": "^3.2.1",
"webpack-merge-and-include-globally": "^2.1.14",
"clean-webpack-plugin": "^1.0.0"
},
"dependencies": {
"@aspnet/signalr": "^1.1.0",
"@aspnet/signalr-protocol-msgpack": "^1.1.0",
"axios": "^0.18.0",
"bootstrap": "^4.2.1",
"jquery": "^3.3.1"
},
"scripts": {
"build": "webpack --mode=development",
"watch": "webpack --mode=development --watch",
"release": "webpack --mode=production",
"test": "echo \"Error: no test specified\" && exit 1"
}
}
最后,这是tsconfig.json:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"lib": [ "es6", "dom" ]
},
"exclude": [
"node_modules",
"wwwroot"
]
}
是我,还是某个地方的错误?