When I try to use
import { readFileSync } from 'fs';
I get the error
Module not found: Error: Can't resolve 'fs'
In fact, when I use readFileSync
in my program in VS even the intellisense works fine, but when I run ng serve
it comes up with a compiler error.
I've spent hours looking at other SO posts and searching the internet. Nothing has worked. For example, have tried setting "types": ["node"]
where previously it was empty. Have tried using a strange ///
syntax for importing, but that didn't work either.
I've also tried strange syntax like import { fs } from '@types/node';
.
I'm using fs for the following socket.io
call:
this.socket = io('https://12.123.1245:1234', { ca: readFileSync('./assets/cert.pem'), rejectUnauthorized: false });