我有一个旧的Angular项目我试图运行,但每次服务应用程序时出现以下错误都会失败:
ERROR in /Users/sam/lifeai/therealdeal/conversational-website/src/app/app.module.ts (8,30): Cannot find module 'ng-socket-io/socket-io.module'.
ERROR in /Users/sam/lifeai/therealdeal/conversational-website/src/app/app.module.ts (9,30): Cannot find module 'ng-socket-io/socketIoConfig'.
ERROR in ./src/app/app.module.ts
Module not found: Error: Can't resolve 'ng-socket-io/socket-io.module' in '/Users/sam/lifeai/therealdeal/conversational-website/src/app'
@ ./src/app/app.module.ts 14:0-63
@ ./src/main.ts
@ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
在我的app.module中,我这样导入它:
import {SocketIoModule} from 'ng-socket-io/socket-io.module';
import {SocketIoConfig} from 'ng-socket-io/socketIoConfig';
const config: SocketIoConfig = {url: 'https://api.CENSOR.com:3000/', options: {secure: true}};
...
imports: [
SocketIoModule.forRoot(config)
]
最后,这就是我从组件中导入它的方式:
import {Socket} from 'ng-socket-io';
参考这个:Angular 2: error TS2307: Cannot find module 'socket.io-client',我似乎找不到一个打字文件。我该怎么办?