Closed hawkins closed 7 years ago
Not really sure what's the problem, as I am unable to reproduce it. Have you tried removing node-modules and install & build again? I have been in situations where this just solved the rebuild issues.
$ npm install -g electron-rebuild
$ rm -rf node_modules
$ npm install
$ electron-rebuild -f -w ad-block
Embarrassingly enough, deleting node_modules
and reinstalling everything fixed that particular error. However, I'm now presented with a missing path error and I can't tell where it's coming from:
$ ./node_modules/.bin/electron-rebuild -f -w ad-block
✖ Rebuild Failed
An unhandled error occurred inside electron-rebuild
Path must be a string. Received undefined
TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.resolve (path.js:1146:7)
at _callee2$ (/Users/hawkins/git/twitch-flow/node_modules/electron-rebuild/lib/rebuild.js:306:67)
at tryCatch (/Users/hawkins/git/twitch-flow/node_modules/electron-rebuild/node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (/Users/hawkins/git/twitch-flow/node_modules/electron-rebuild/node_modules/regenerator-runtime/runtime.js:337:22)
at Generator.prototype.(anonymous function) [as next] (/Users/hawkins/git/twitch-flow/node_modules/electron-rebuild/node_modules/regenerator-runtime/runtime.js:96:21)
at tryCatch (/Users/hawkins/git/twitch-flow/node_modules/electron-rebuild/node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (/Users/hawkins/git/twitch-flow/node_modules/electron-rebuild/node_modules/regenerator-runtime/runtime.js:279:24)
at Generator.prototype.(anonymous function) [as next] (/Users/hawkins/git/twitch-flow/node_modules/electron-rebuild/node_modules/regenerator-runtime/runtime.js:96:21)
at Generator.tryCatcher (/Users/hawkins/git/twitch-flow/node_modules/bluebird/js/release/util.js:16:23)
at PromiseSpawn._promiseFulfilled (/Users/hawkins/git/twitch-flow/node_modules/bluebird/js/release/generators.js:97:49)
at Promise._settlePromise (/Users/hawkins/git/twitch-flow/node_modules/bluebird/js/release/promise.js:574:26)
at Promise._settlePromise0 (/Users/hawkins/git/twitch-flow/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/hawkins/git/twitch-flow/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/Users/hawkins/git/twitch-flow/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/Users/hawkins/git/twitch-flow/node_modules/bluebird/js/release/async.js:143:10)
Hmm, I just checked the source code of electron-rebuild and I think the node-modules path is missing for some reason. Can you try to add the --module-dir
option to the path of the node_modules
folder? You might have to reinstall the module first like before, not sure though.
$ npm install -g electron-rebuild
$ rm -rf node_modules
$ npm install
$ electron-rebuild -f -w ad-block --module-dir=node_modules
Please post another stack trace if it doesn't work. Also, are you running electron-rebuild as a global command or as a dev dependency? I always run it as a dev dependency and it just works, so maybe this is because it is the global installation that causes an undefined path to node-modules. Hope this extra option fixes the issue! If it doesn't and you want to try it as a dev dependency (like I do) - run this script (and this one works on my macbook pro, same configuration).
$ npm install --save-dev electron-rebuild
$ rm -rf node_modules
$ npm install
$ ./node_modules/.bin/electron-rebuild -f -w ad-block
Looks like module-dir
is assumed to be the current directory, since it checks for a package.json
in the specified folder. Here's the result of passing module-dir:
$ ./node_modules/.bin/electron-rebuild -f -w ad-block --module-dir=node_modules
✖ Rebuild Failed
An unhandled error occurred inside electron-rebuild
ENOENT: no such file or directory, open '/Users/hawkins/git/twitch-flow/node_modules/package.json'
Error: ENOENT: no such file or directory, open '/Users/hawkins/git/twitch-flow/node_modules/package.json'
I've tried specifying the current directory to be sure:
$ ./node_modules/.bin/electron-rebuild -f -w ad-block --module-dir=.
✖ Rebuild Failed
An unhandled error occurred inside electron-rebuild
Path must be a string. Received undefined
TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.resolve (path.js:1146:7)
at _callee2$ (/Users/hawkins/git/twitch-flow/node_modules/electron-rebuild/lib/rebuild.js:306:67)
at tryCatch (/Users/hawkins/git/twitch-flow/node_modules/electron-rebuild/node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (/Users/hawkins/git/twitch-flow/node_modules/electron-rebuild/node_modules/regenerator-runtime/runtime.js:337:22)
at Generator.prototype.(anonymous function) [as next] (/Users/hawkins/git/twitch-flow/node_modules/electron-rebuild/node_modules/regenerator-runtime/runtime.js:96:21)
at tryCatch (/Users/hawkins/git/twitch-flow/node_modules/electron-rebuild/node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (/Users/hawkins/git/twitch-flow/node_modules/electron-rebuild/node_modules/regenerator-runtime/runtime.js:279:24)
at Generator.prototype.(anonymous function) [as next] (/Users/hawkins/git/twitch-flow/node_modules/electron-rebuild/node_modules/regenerator-runtime/runtime.js:96:21)
at Generator.tryCatcher (/Users/hawkins/git/twitch-flow/node_modules/bluebird/js/release/util.js:16:23)
at PromiseSpawn._promiseFulfilled (/Users/hawkins/git/twitch-flow/node_modules/bluebird/js/release/generators.js:97:49)
at Promise._settlePromise (/Users/hawkins/git/twitch-flow/node_modules/bluebird/js/release/promise.js:574:26)
at Promise._settlePromise0 (/Users/hawkins/git/twitch-flow/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/hawkins/git/twitch-flow/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/Users/hawkins/git/twitch-flow/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/Users/hawkins/git/twitch-flow/node_modules/bluebird/js/release/async.js:143:10)
Also so we're clear, I'm also using this as a dev-dependency.
I've followed the exact steps you provided (installing as dev dep, remove node_modules, reinstall all modules, rebuild) for my previous comment and again for this comment, but it yielded the same error and stacktrace.
Can you tell me what version of electron-rebuild you have installed? I'm wondering if this has changed recently; I'm using 1.5.7
Sorry for late response. Have you already found a solution for this?
I am also using electron-rebuild v1.5.7
.
No, I was not yet able to find a solution.
Unfortunately, my schedule won't allow much time to debug this for a few weeks so I figure it may be best to close this issue, since it likely isn't truly an issue of electron-ad-blocker
's in the first place. I'll leave closing up to your discretion though, as other users may run into this issue in the future.
When I manage to come back to this issue, I'll be sure to leave a comment with the results of next efforts. Thanks so much for your help so far, though!
Allright, I'll close it for now but I will also try to solve this when I find the time. Thanks for the report!
Hey @Jense5, @hawkins I'm also seeing the same 'Path must be a String. received undefined' error. I know it's not really a problem with your project but any help would be appreciated!
It seems to be because of this line in rebuild.js of electron-rebuild project.
The .find((file) => file !== '.node' && file.endsWith('.node')));
returns undefined because there is no *.node file in that directory.
If you run it with DEBUG=electron-rebuild ./node_modules/.bin/electron-rebuild -f -w ad-block --module-dir=.
you can see what your output is and compare.
These are the files/directories I see in that directory (node_modules/cppunitlite/build/Release), the last debug line before it blows up:
electron-rebuild testing files [ '.deps', '.forge-meta', 'CppUnitLite.a', 'obj.target', 'test' ] +0ms
Now I have managed to hack my way around this to get it working by simply checking the result of the .find before passing it into the path.resolve call:
let np = (yield fs.readdir(path.resolve(modulePath, 'build/Release'))).find((file) => file !== '.node' && file.endsWith('.node'));
d('result of find for .node file', np);
if(np){
const nodePath = path.resolve(modulePath, 'build/Release', (yield fs.readdir(path.resolve(modulePath, 'build/Release')))
.find((file) => file !== '.node' && file.endsWith('.node')));
const abiPath = path.resolve(modulePath, `bin/${process.platform}-${this.arch}-${this.ABI}`);
if (yield fs.exists(nodePath)) {
d('found .node file', nodePath);
d('copying to prebuilt place:', abiPath);
yield fs.mkdirs(abiPath);
yield fs.copy(nodePath, path.resolve(abiPath, `${moduleName}.node`));
}
}
this.lifecycle.emit('module-done');
Thanks for the info. What version of electron are you using? It looks like I am able to reproduce the issue with electron v1.7.1-beta
, but any v1.6.x
is working. Might be the same error as described in issue #4.
Hey, not sure if this is an ad-block specific problem or what but I figured I'd ask you here.
Following your instructions in the readme, I've received the following error:
This repeats another time.
System
I'm running this on a MacBook Pro running MacOS 10.12.4 , with Xcode installed for node-gyp to work.
Repro
electron-ad-blocker
Any ideas whats going on?