When I compile the projcet with npm run make and try to run any of them linux/nt/macos it does not open a window I tried to look at the log and theres nothing when running npm start tho everything works fine when I used asar: true, it fixs it but then I can’t edit file I need to for repos
index.js
const { ipcMain, app, BrowserWindow } = require('electron');
const path = require('path');
const fs = require('fs');
function createWindow() {
const mainWindow = new BrowserWindow({
width: 1700,
height: 900,
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
preload: path.join(__dirname, 'preload.js') // Correcting path using path.join
}
});
// Load the index.html of the app
mainWindow.loadFile('index.html');
// Correctly load the index.html of the app
// mainWindow.loadURL(url.format({
// pathname: path.join(__dirname, 'index.html'),
// protocol: 'file:'
// }));
// Open the DevTools (optional, for debugging purposes)
mainWindow.webContents.openDevTools();
}
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
ipcMain.handle('read-file', async (event, filePath) => {
try {
const content = fs.readFileSync(path.join(app.getAppPath(), filePath), 'utf8');
return content;
} catch (error) {
console.error('Failed to read file:', error);
throw error;
}
});
ipcMain.handle('save-file', async (event, filePath, content) => {
try {
fs.writeFileSync(path.join(app.getAppPath(), filePath), content, 'utf8');
} catch (error) {
console.error('Failed to save file:', error);
throw error;
}
});
// Do not add more functions to read data just use these functions and js in your repo
Package.json
{
"name": "hundros",
"version": "1.0.3",
"description": "Hundros is a repo based torrent engine deisgend for whatever the user want's just pls respect copyright law.",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1",
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"build": "./build.sh"
},
"keywords": [],
"author": "HttpAnimation",
"license": "ISC",
"devDependencies": {
"@electron-forge/cli": "^7.3.1",
"@electron-forge/maker-deb": "^7.3.1",
"@electron-forge/maker-rpm": "^7.3.1",
"@electron-forge/maker-squirrel": "^7.3.1",
"@electron-forge/maker-zip": "^7.3.1",
"@electron-forge/plugin-auto-unpack-natives": "^7.3.1",
"@electron-forge/plugin-fuses": "^7.3.1",
"electron": "^29.3.0"
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0"
}
}
Forge config
const path = require('path');
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
const { FuseV1Options, FuseVersion } = require('@electron/fuses');
module.exports = {
packagerConfig: {
asar: false,
icon: path.resolve(__dirname, 'images/icon.png') // Adjust the path to your icon file
},
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {
iconUrl: path.resolve(__dirname, 'images/icon.ico'), // Windows icon
},
},
{
name: '@electron-forge/maker-zip',
platforms: ['linux', 'darwin'],
config: {
icon: path.resolve(__dirname, 'images/icon.png') // macOS and Linux icon
},
},
{
name: '@electron-forge/maker-deb',
config: {
icon: path.resolve(__dirname, 'images/icon.png'), // Linux icon
"compression": "gzip"
},
},
{
name: '@electron-forge/maker-rpm',
config: {
icon: path.resolve(__dirname, 'images/icon.png'), // Linux icon
},
}
],
plugins: [
new FusesPlugin({
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
[FuseV1Options.EnableNodeCliInspectArguments]: false,
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
[FuseV1Options.OnlyLoadAppFromAsar]: true,
}),
],
};
aser = true works but can’t edit
aser = false does not work at all
New contributor
HttpAnimations is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1