在我的服务文件中,我导入这四个库:
import * as async from "async";
import * as officegen from "officegen";
import * as path from "path";
import * as fs from "fs";
虽然async、officegen和path没有问题。 fs 行不断给出此错误:
ERROR in src/app/matieres/matiere.service.ts(11,45): error TS2307: Cannot find module 'fs'.
在绝望的尝试中,我尝试了这些:
npm install fs -g
npm install fs --save
npm install file-system -g
npm install file-system --save
没有一个有效 这实在令人困惑。 有人可以帮忙吗?
最佳答案
您可能需要使用npm install --save-dev @types/node
可能还需要检查 tsconfig.json 中的 "moduleResolution": "node"
如果这没有帮助,这些其他问题看起来类似:
关于node.js - 在 Angular 应用程序中,我不断收到此错误 Cannot find module 'fs',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56546970/