gpt4 book ai didi

node.js - 在 Angular 应用程序中,我不断收到此错误 Cannot find module 'fs'

转载 作者:太空宇宙 更新时间:2023-11-04 02:45:11 24 4
gpt4 key购买 nike

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

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"

如果这没有帮助,这些其他问题看起来类似:

Cannot find module 'fs'

Use fs in typescript

关于node.js - 在 Angular 应用程序中,我不断收到此错误 Cannot find module 'fs',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56546970/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com