我使用电子和反应,反应应用程序是用创建-反应-应用程序样板创建的。我需要使用电子API打开外部链接,但这项任务是通过一个反应组件实现的。我在react组件中导入了远程电子(以便访问当前窗口)。但这给了我一个错误
const {remote} = require("electron")
错误来自电子本身,来自node_modules/electron/index.js,问题在于fs模块,它说:
TypeError: fs.existsSync is not a function
这一错误显示在电子窗口中。
我很难整合电子。当我像在中描述的那样使用它时,一切都正常。当我想使用导入电子(electron.remote)在Angular2服务中使用它,让应用程序使用诸如系统对话框和文件系统访问之类的桌面功能时,问题就开始了。
加载应用程序时,在webpack包中包含的electron/index.js中,我得到了以下错误:
Uncaught TypeError: fs.existsSync is not a function (index.js:6)
该文件看起来非常简单:
var fs = require('fs')
var path = require('path'
我正在建立跨平台的桌面应用程序使用电子和ReactJS与打字。所以有一个类似下面的函数。该功能是在单击按钮时调用的,它应该在连接的默认打印机中打印文本。这是一个处理打印操作的第三方库。但问题是,当我使用此功能时,我的应用程序无法加载。它就会崩溃。
function printcheck() {
const printer = require('electron-print');
app.on('ready', function() {
printer.print("Text sent to pri
我用电子制作我的项目。它在Nodejs上运行。我用电子包装机编写了这个项目.它正在运行,但是当我移动已编译的文件夹时,项目将不会运行--我会得到一些路径错误。
export function getSafeWPPath(): string {
let home = app.getPath('home');
home = path.resolve(home, ".SafeWP");
if (!fs.existsSync(home)) {
fs.mkdirSync(home);
}
return h
我有一个Node中的项目和类型记录,其中有一个带有类的文件,用于检查目录是否存在并创建另一个目录。对于该方法,我传递两个参数:主目录('src/out')和创建以下目录('api')的字符串。
这是我的类,dir变量('src / out')和api变量('api'):
export class createDir {
checkExistsOrCreate(dir: string, api: any) {
let dire = `${dir}${api}`;
if (!fs.existsS
我正在用柏树测试我的电子应用程序。由于Cypress使用浏览器模式,因此不支持FS。所以我得到了这个错误:
Error in mounted hook: "TypeError: fs.existsSync is not a function"
我在文件上发现了这个:
所以我在我的测试中加入了这个:
it('Sample test', () => {
cy.task('readSettingsJson', settingsFolder).then((content) => {
// This can print th
有什么办法从"main.js“电子中保存一个文件的星体?
我正在用这个命令来指出只写区域的出路,但我做不到。
这将是很好的路径是在内部的/my-project/resources/,并将工作,即使没有电子封装。
let configFilePath = `${__dirname}/../config.json`
db = new loki(configFilePath)
if(fs.existsSync(configFilePath))
db.loadDatabase()
我有一个问题,当我的React应用程序加载时,我得到了一个TypeError: fs.existsSync is not a function错误。
我正在尝试为我的自定义MacOS按钮添加功能,然而,当我看起来像是在使用import {remote} from 'electron'时,我得到了这个错误。
这是组件源代码:这是在控制台中生成的错误:
这看起来是一个电子问题,但我似乎找不出原因。
任何帮助或建议都将不胜感激。
当我在做我的项目时,我的电子窗口给出了这个错误。 TypeError: fs.existsSync is not a function
getElectronPath
../node_modules/electron/index.js:7
4 | var pathFile = path.join(__dirname, 'path.txt')
5 |
6 | function getElectronPath () {
> 7 | if (fs.existsSync(pathFile)) {
8 | var executablePat
在node.js中同步和异步检查现有文件有什么不同?
例如:
var path = require('path');
if (path.existsSync("/the/path")) { // or fs.existsSync
// ...
}
和
// Is it a directory?
lstat('/the/path', function(err, stats) {
if (!err && stats.isDirectory()) {
// Yes it is
}
});
在我的节点应用程序中,我有一个init函数:
function init() {
if (!fs.existsSync("../schedule.json"))
fs.createReadStream('../template.json').pipe(fs.createWriteStream('../schedule.json'));
var content = fs.readFileSync("../schedule.json", "utf8");
return JSO
所以我试图在读取文件之前检查该文件是否存在,但是如果我将检查放在读取之前,那么即使数据存在,读取也变得一无是处。
我试着把它放在下面,但我的文件在试图从一个空文件中读取时会出现错误。
bot.on('chat', function(username, message) {
var time = clock.zonedDateTime('SYSTEM').toString()
if (!fs.existsSync('C:/Users/La Fam/Desktop/kekbot_rewritten(tm)
因此,我正在构建一个电子和反应应用程序。我正在使用ghost-script来创建某些pdf文件的imgs,我想知道如何告诉Node.js在打开窗口和更改应用程序中的状态之前等待imgs被创建。这些img被用作组件的src,当组件试图加载img时,它在某种程度上保留了一个中断状态,因为当状态更新时,img src不存在。
// this is where I set the state before sending all the data to the renderer process(the front end of the App)
function getStateReady(the
我正在测试,当Excel文件被下载时,它应该验证文件中的数据。我有这两种规格:
it('should be able to download the excel file of the student data', async function(){
expect( homePage.ExcelFieDownloaded()).toBe(true);
});
it('Should match total records in Excel File with the data table', async function(){
expect
在下面的代码中,我解压了一个文件夹,并在解压后验证了其中的文件。但是,我可以手动查看mac中的文件,尽管代码我不能断言它。fs.existsSync断言它是假的。
const zipFilePath = path.join(zipDirPath, `webfontkit${params.tc}.zip`);
const unzipFolderPath = path.join(outDir, `webfontkit${params.tc}`);
// Execute request for kit API and save response zip files
await utils.exec
我正在用ES6重写我的电子应用程序,使用Laravel编写应用程序JS和SASS。现在,主进程很好地加载了呈现过程。一旦发生这种情况,我的app.js就会加载,这就是我遇到问题的地方。所以我想:
import { remote } from 'electron';
这将导致控制台中的此错误:
Uncaught Error: Electron failed to install correctly, please delete node_modules/electron and try installing again
现在我试着重新安装电子,即使当主进程开始时,电子也能工作。该