While working on implementing a chat feature for my project using sockJS and STOMP, I encountered several challenges with installing these two libraries. Despite attempting various methods such as installation from index.html, npm install, and manual download of min files into the assets folder, I thought I had successfully installed them.
import * as Stomp from 'stompjs';
import * as SockJS from 'sockjs-client';
After adding the above code snippet, I no longer received errors in my typescript file (although there were still error indicators on the import declarations). By choosing a quick fix option to 'download missing types,' the issue resolved itself mysteriously.
Continuing to work on my code in a minimalistic approach just for a quick test, I was disheartened when I ran the project only to find that it wasn't functioning properly.
The error message I encountered was:
./node_modules/stompjs/lib/stomp-node.js:14:8-22 - Error: Module not found: Error: Can't resolve 'net' in 'C:\Users\UTENTE\Desktop\CORSO AZIENDA FORMAZIONE\angular-projects\gestionaleFrontEnd\node_modules\stompjs\lib'
Feeling perplexed about how to address this error, I decided to reach out here in hopes of receiving some assistance.
import { Component, OnInit } from '@angular/core';
// Rest of the Angular component code...
Additionally, below is the excerpt from app.module.ts where the error might be located:
// Contents of the app.module.ts file...
Lastly, sharing the contents of package.json for reference:
{
// Package.json content...
}
If further information or details are necessary, please let me know. EDIT: In a similar scenario to mine, I discovered a potential solution in this thread https://github.com/jmesnil/stomp-websocket/issues/119. Therefore, I attempted their proposed fix by running "npm i net -s".
Presently, upon inspecting the index.html and checking the browser console, I am encountering the following error:
Uncaught ReferenceError: global is not defined at Object.5103 (vendor.js:74896)
// More lines of error traceback...
This situation has become quite frustrating, and any guidance or insights would be greatly appreciated. Thank you!