2

In my service file, I import these four libraries:

import * as async from "async";
import * as officegen from "officegen";
import * as path from "path";
import * as fs from "fs";

While there's no problem with async,officegen and path. The fs line keeps giving this error:

ERROR in src/app/matieres/matiere.service.ts(11,45): error TS2307: Cannot find module 'fs'.

In hopeless attempts, I tried these:

npm install fs -g

npm install fs --save

npm install file-system -g

npm install file-system --save

None of which worked This is really confusing. Anyone can help?

Ahmed Ghrib
  • 695
  • 4
  • 13
  • 29

1 Answers1

0

You might need to use npm install --save-dev @types/node

Might also need to check tsconfig.json for "moduleResolution": "node"

If that doesn't help, these other questions look similar:

Cannot find module 'fs'

Use fs in typescript