[ERROR in ./node_modules/stompjs/lib/stomp-node.js Module not found: Error: Can't resolve 'net' in 'C:\ANGULAR\websocket-example\node_modules\stompjs\lib'][1]
将stompjs添加到angular by
npm install stompjs --save
导入component.ts
import * as Stomp from 'stompjs';
使用这种方法时出现错误
let socket = new WebSocket("ws://localhost:8080/greeting");
let ws = Stomp.over(socket);
答案 0 :(得分:0)
要将外部库添加到您的角度项目中,可以将其添加到angular.json
"scripts":[
"node_modules/stompjs/lib/stomp-node.js"
]