- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我对 Angular、Javascript 等话题还很陌生。
我尝试编写一个应该访问文件系统的 (TypeScript) Angular2-Electron 应用程序。每个人都只是说需要“fs”模块,一切都很好,但这对我不起作用……。
如果我这样做:var fs = require('fs');
我可以看到我的应用程序尝试从我的应用程序根文件夹加载“fs”模块:..myapp/dist/fs net::ERR_FILE_NOT_FOUND
我的所有其他外部模块都在 index.html 中引用:
<!-- build:js app/scripts/combined.js -->
<script src="../node_modules/jquery/dist/jquery.js"></script>
<script src="../node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="../node_modules/systemjs/dist/system.js"></script>
<script src="../node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="../node_modules/angular2/bundles/http.js"></script>
<script src="../node_modules/angular2/bundles/router.js"></script>
<script src="../node_modules/rxjs/bundles/Rx.js"></script>
<script src="../node_modules/bootstrap/dist/js/bootstrap.js"></script>
<script src="../node_modules/pdfjs-dist/build/pdf.combined.js"></script>
<script src="boot.js" type="text/javascript"></script>
<!-- endbuild -->
因此我认为可以找到它们,但是“fs”属于 Electron 中存在的 node.js?还是我在思想上犯了一些大错误?
非常感谢,
克里斯
最佳答案
问题似乎是我在 Angular 应用程序中使用了 SystemJS。 SystemJS 尝试从我自己的应用程序加载模块。
我现在添加了这个,所以我的 index.html 似乎可以工作了:
<script>
if (require) {
window.$ = window.jQuery = require('./app/assets/js/jquery.min.js');
window.fs = require('fs');
window.path = require('path');
}
</script>
关于typescript - Electron ,Angular2, "fs",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36663454/
我正在尝试将我的Node.js项目迁移到Bun。我的项目在很多地方使用了‘fs’包。我发现了许多Bun迁移示例,它们将‘fs’包导入为‘node:FS’。但是,作为“文件系统”导入可以很好地工作,没有
我正在尝试将我的Node.js项目迁移到Bun。我的项目在很多地方使用了‘fs’包。我发现了许多Bun迁移示例,它们将‘fs’包导入为‘node:FS’。但是,作为“文件系统”导入可以很好地工作,没有
我正在使用 aws lambda。 我有一个 .p8 文件,用于发送 apns 通知。因为我不能使用相对或绝对路径,因为它没有服务器。我必须从 s3 url 读取它。为此我做了这个 let file
我相信以下所有命令都可用于将 hdfs 文件复制到本地文件系统。有什么区别/情境利弊。 (这里是 Hadoop 新手)。 hadoop fs -text /hdfs_dir/* >> /local_d
这是一个新手问题,但我有点困惑为什么需要 open 与 r 、 w 、 a 以及这些标志的所有变体。如果他/她想读取或写入文件而不是使用 open,难道不应该简单地使用 readFile 或 writ
我想在 JavaScript 中使用 import fs from 'fs'。这是一个示例: import fs from 'fs' var output = fs.readFileSync('som
我的公司正在执行 SVN 存储库迁移,我想避免两个存储库(目前都处于事件状态)之间的修订号重叠。 我的要求是将新存储库的修订强制为特定的修订号(例如:100.000)。 通过分析 FSFS 存储库,我
-put和-copyFromLocal被记录为相同,而大多数示例使用详细的变体-copyFromLocal。为什么? -get和-copyToLocal相同 最佳答案 copyFromLocal与pu
我正在调用 Google 云端硬盘的下载 API,然后我想使用 fs.writeFile 或 fs.writeFileSync 在本地写入下载的文件。这就是我正在做的事情: const wri
我正在学习一些教程,但无法理解为什么这一行“self.only_dirs.push(files[i]);”导致有关它“未定义”的错误。这肯定是一个变量范围问题,但我尝试过的都没有成功。我需要如何声明变
我是第一次尝试 phantomJS,我已经成功地从站点中提取了 som 数据,但是当我尝试将一些内容写入文件时,我收到错误:ReferenceError:找不到变量:fs 这是我的脚本 var pag
这是一个 Node 应用程序,运行 Express 服务器。我有一个包含文本文件的文件夹。我需要能够进入文件夹内的每个文件,并提取包含单词“SAVE”的行。 我被困在这一步了。 app.get('/l
我在 fs.chunks 中有 10 GB 的数据,我想删除不在 fs.files 上的所有文档。我已经删除了我不想要的 fs.files 中的每个条目,所以 fs.files 中的每个 id 都是我
我注意到官方 Node 文档对 fs.exists 的描述令人吃惊: "fs.exists() is an anachronism and exists only for historical rea
我用 require("fs").promises只是为了避免使用回调函数。 但是现在,我也想用fs.createReadstream使用 POST 请求附加文件。 我怎样才能做到这一点? 或者在这种
我正在使用 Electron 和 React 编写桌面应用程序。我想将一些信息存储在 JSON 文件中。我试过 web-fs 和 browserify-fs 来完成这个,但都没有按预期工作。我的设置如
其中哪一个更适合在 Node 服务器应用程序的文件管理器类型中处理文件读/写操作? 一个比另一个快吗?速度非常重要,因为该应用程序应该能够同时处理许多用户请求 最佳答案 流的独特之处在于,不是程序像传
我需要递归或不递归地遍历文件夹(给定 bool 参数)。我发现有 fs::recursive_directory_iterator() 和 fs::directory_iterator()。在 Jav
AFAICT,如果我正在编写一个库并使用 Promise.promisifyAll(fs);,这会修改 fs 模块(而不是返回修改后的复制)。因此,如果有人导入我的库,这也会对他们修改 fs 产生副作
我正在使用带有以下导入代码的 fs 模块 导入 fs = require('fs') 代码一直运行,直到在下面的 TypeScript 代码的第二行遇到此异常 const filePath = 'da
我是一名优秀的程序员,十分优秀!