在Angular应用程序中,我不断收到此错误找不到模块'fs'

时间:2019-06-11 15:23:16

标签: node.js angular

在我的服务文件中,导入以下四个库:

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

尽管异步,officegen和路径没有问题。 fs行不断显示此错误:

  src / app / matieres / matiere.service.ts(11,45)中的

ERROR:错误TS2307:   找不到模块“ fs”。

在绝望的尝试中,我尝试了以下方法:

  

npm安装fs -g

     

npm install fs --save

     

npm安装文件系统-g

     

npm安装文件系统--save

没有一个有效 这真是令人困惑。 有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

您可能需要使用npm install --save-dev @types/node

可能还需要检查tsconfig.json中是否有"moduleResolution": "node"

如果这没有帮助,那么其他问题看起来很相似:

Cannot find module 'fs'

Use fs in typescript

相关问题