Error while compiling the angular project

1.1k Views Asked by At
[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]

added stompjs to angular by npm install stompjs --save

imported into component.ts import * as Stomp from 'stompjs';

and got error when using like this let socket = new WebSocket("ws://localhost:8080/greeting"); let ws = Stomp.over(socket);

1

There are 1 best solutions below

0
On

To add an external library to your angular project, you can add those to the angular.json

"scripts":[
   "node_modules/stompjs/lib/stomp-node.js"
]