Closed BlossomiShymae closed 2 years ago
Okie dokie, so after cloning and installing dependencies for this repository, I came across this error warning when trying to build for Windows:
$ yarn build:win
yarn run v1.22.11
$ pkg -o opgg-ads-remover -t node16-win-x64 index.js
> pkg@5.7.0
> Fetching base Node.js binaries to PKG_CACHE_PATH
fetched-v16.15.0-win-x64 [====================] 100%
> Warning Failed to make bytecode node16-x64 for file C:\snapshot\opgg-ads-remover\index.js
Done in 8.29s.
Running with --debug
flag for pkg
brings up what happened:
> [debug] Targets:
[
{
"nodeRange": "node16",
"platform": "win",
"arch": "x64",
"output": "C:\\git\\opgg-ads-remover\\opgg-ads-remover.exe",
"forceBuild": false,
"fabricator": {
"nodeRange": "node16",
"platform": "win",
"arch": "x64",
"binaryPath": "C:\\Users\\11opi_kt\\.pkg-cache\\v3.4\\fetched-v16.15.0-win-x64"
},
"binaryPath": "C:\\Users\\11opi_kt\\.pkg-cache\\v3.4\\fetched-v16.15.0-win-x64"
}
]
C:\snapshot\opgg-ads-remover\index.js:1
(function (exports, require, module, __filename, __dirname) { import { extractAll, createPackageWithOptions } from "asar";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at new Script (node:vm:101:7)
at Socket.<anonymous> ([eval]:18:19)
at Socket.emit (node:events:527:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
C:\snapshot\opgg-ads-remover\index.js:1
(function (exports, require, module, __filename, __dirname) { import { extractAll, createPackageWithOptions } from "asar";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at new Script (node:vm:101:7)
at Socket.<anonymous> ([eval]:18:19)
at Socket.emit (node:events:527:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
> Warning Failed to make bytecode node16-x64 for file C:\snapshot\opgg-ads-remover\index.js
Done in 3.87s.
After doing some googling, it appears that pkg
does not support ESM-style imports. Changing the imports to use CommonJS-style instead fixes the issue but brings up another problem:
$ ./opgg-ads-remover.exe
Killing OPGG process
node:fs:1405
handleErrorFromBinding(ctx);
^
Error: ENOENT: no such file or directory, scandir 'op-gg-unpacked/assets/react'
at Object.readdirSync (node:fs:1405:3)
at readdirSync (pkg/prelude/bootstrap.js:1309:35)
at rebuildAddDir (C:\snapshot\opgg-ads-remover\index.js)
at main (C:\snapshot\opgg-ads-remover\index.js)
at Object.<anonymous> (C:\snapshot\opgg-ads-remover\index.js)
at Module._compile (pkg/prelude/bootstrap.js:1930:22)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.runMain (pkg/prelude/bootstrap.js:1983:12) {
errno: -4058,
syscall: 'scandir',
code: 'ENOENT',
path: 'op-gg-unpacked/assets/react'
}
So I saw this warning not error from pkg when I builded the app and it appeared that it did not affect the .exe when I it runned on my computer so I'm pretty surprised that it did not work for you.
It appears that you're trying to run the .exe from powershell on this exemple, I want to be sure that you runned the .exe from your GUI so: Have you tried to execute the .exe from your GUI and if yes did your OPGG still had ads ?
When running the v.1.0 .exe from my GUI, it did not work as the OP.GG app was not killed and the ads appear even after restarting it. I was just running the .exe in my terminal to troubleshoot and find out the problem.
When running the v.1.0 .exe from my GUI, it did not work as the OP.GG app was not killed and the ads appear even after restarting it. I was just running the .exe in my terminal to troubleshoot and find out the problem.
Okay so I'm gonna look into it tomorow and try to find an alternative to PKG to stay with ESM modules either way I'll accept your PR if it passes the test I'll had later.
So I think I found a workaround, I'm gonna try to implement Rollup npm lib to compile the code to CommonJS then use PKG to build the executable.
It'll allow us to keep the ESM codebase while staying with pkg untill they release their ESM handlement.
@MissUwuieTime okay so I worked on a patch, I can't test it at the moment as I don't currently have a Windows machine but would you be able to test the fix on this branch and make me some feedback if it works or not ?
I know that there is a warning from rollup when "compiling" to cjs but it doesn't look like a prob when pkg is building the exe
@MidKnightXI I tested the branch fix (run from GUI and terminal). Building the code came with a warning as you mentioned, but it was successful. Running from GUI launches the console before quickly closing. The OP.GG app wasn't killed and the ads weren't removed.
It solves the Error: Cannot find module
issue, but not the later issue that occurs as stated in my 2nd comment. Running from terminal:
$ ./opgg-ads-remover.exe
Killing OPGG process
node:fs:1405
handleErrorFromBinding(ctx);
^
Error: ENOENT: no such file or directory, scandir 'op-gg-unpacked/assets/react'
at Object.readdirSync (node:fs:1405:3)
at Object.readdirSync (pkg/prelude/bootstrap.js:1309:35)
at rebuildAddDir (C:\snapshot\opgg-ads-remover-patch-fixing-esm-imports\bundle.js)
at main (C:\snapshot\opgg-ads-remover-patch-fixing-esm-imports\bundle.js)
at Object.<anonymous> (C:\snapshot\opgg-ads-remover-patch-fixing-esm-imports\bundle.js)
at Module._compile (pkg/prelude/bootstrap.js:1930:22)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.runMain (pkg/prelude/bootstrap.js:1983:12) {
errno: -4058,
syscall: 'scandir',
code: 'ENOENT',
path: 'op-gg-unpacked/assets/react'
}
This commit should be able to solve the Error: ENOENT: no such file or directory, scandir 'op-gg-unpacked/assets/react'
.
@MissUwuieTime I pushed the fix on the same branch if you want to test it 👍🏻
@MissUwuieTime I pushed the fix on the same branch if you want to test it 👍🏻
The same error occurs when building and running the executable of the fix commit on that same branch:
Killing OPGG process
node:fs:1405
handleErrorFromBinding(ctx);
^
Error: ENOENT: no such file or directory, scandir 'op-gg-unpacked\assets\react' at Object.readdirSync (node:fs:1405:3)
at Object.readdirSync (pkg/prelude/bootstrap.js:1309:35)
at rebuildAddDir (C:\snapshot\opgg-ads-remover-patch-fixing-esm-imports\bundle.js)
at main (C:\snapshot\opgg-ads-remover-patch-fixing-esm-imports\bundle.js)
at Object.<anonymous> (C:\snapshot\opgg-ads-remover-patch-fixing-esm-imports\bundle.js)
at Module._compile (pkg/prelude/bootstrap.js:1930:22)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.runMain (pkg/prelude/bootstrap.js:1983:12) {
errno: -4058,
syscall: 'scandir',
code: 'ENOENT',
path: 'op-gg-unpacked\\assets\\react'
}
I made a new pull request for the patch branch that includes my fix that solves the ENOENT
error. The extractAll
function has to be called before readdirSync
or the unpacked folder will never be created by the time it is read.
Testing this PR on Windows works when run by GUI (OP.GG killed, no ads). I don't have a Darwin-based machine so that needs to be tested there.
Just merged your PR 👍
Hi,
I wanted to try out your application but ran into a problem. Executing the application normally does not appear to remove the ads from the OP.GG desktop app or do anything at all.
Steps to reproduce
opgg-ads-remover-v1-0-win
archiveopgg-ads-remover.exe
Current behaviour (bug)
Ads are not removed in the OP.GG desktop app.
Expected behaviour (correct)
Ads should be removed in the OP.GG desktop app.
Relevant logs and/or media (optional)
System information
The issue appears to be
index.js
not being found. Maybe it has something to do with the way the application was packaged? I see this project usespkg
for building, but I have no experience with using that npm package.