Bug description
The bundled app cannot load preload.js.
Steps to reproduce
Give your full nativefier command, with the --verbose flag, on a public site:
Expected behavior
No errors
Actual behavior
init.ts:206 Unable to load preload script: /Users/.../Repositories/AppBundler/Facebook-darwin-x64/Facebook.app/Contents/Resources/app/lib/preload.js
(anonymous) @ init.ts:206
init.ts:207 Error: Cannot find module 'loglevel'
Require stack:
- /Users/.../Repositories/AppBundler/Facebook-darwin-x64/Facebook.app/Contents/Resources/app/lib/preload.js
at Module._resolveFilename (internal/modules/cjs/loader.js:798)
at Function../lib/common/reset-search-paths.ts.Module._resolveFilename (reset-search-paths.ts:40)
at Module._load (internal/modules/cjs/loader.js:691)
at Module._load (electron/js2c/asar.js:717)
at Function.Module._load (electron/js2c/asar.js:717)
at Module.require (internal/modules/cjs/loader.js:853)
at require (internal/modules/cjs/helpers.js:74)
at Object.<anonymous> (/Users/.../Repositories/AppBundler/Facebook-darwin-x64/Facebook.app/Contents/Resources/app/lib/preload.js:21)
at Object.<anonymous> (/Users/.../Repositories/AppBundler/Facebook-darwin-x64/Facebook.app/Contents/Resources/app/lib/preload.js:68)
at Module._compile (internal/modules/cjs/loader.js:968)
(anonymous) @ init.ts:207
MwLb-ei-a-s.js?_nc_x=Ij3Wp8lg5Kz:47 ErrorUtils caught an error:
Cannot access 'INJECT_JS_PATH' before initialization
Subsequent errors won't be logged; see https://fburl.com/debugjs.
b @ MwLb-ei-a-s.js?_nc_x=Ij3Wp8lg5Kz:47
/Users/.../Repositories/AppBundler/Facebook-darwin-x64/Facebook.app/Contents/Resources/app/lib/preload.js:46 Uncaught ReferenceError: Cannot access 'INJECT_JS_PATH' before initialization
at injectScripts (/Users/.../Repositories/AppBundler/Facebook-darwin-x64/Facebook.app/Contents/Resources/app/lib/preload.js:46)
at HTMLDocument.<anonymous> (/Users/.../Repositories/AppBundler/Facebook-darwin-x64/Facebook.app/Contents/Resources/app/lib/preload.js:16)
Context
Please provide the information requested by https://github.com/jiahaog/nativefier/blob/master/.github/ISSUE_TEMPLATE/bug_report.md
I'm having same issue.
Nativefier: 8.0.6
Node.js: v13.12.0 (tried with LTS also)
Npm: 6.14.4
OS: OSX 10.11.6 (15G22010)
Installed everything today, made around 12 different builds error is always happening.
Error when looking at the finished build with dev tools.
Always the same:
Unable to load preload script: /Users/kiki/APP-darwin-x64/APP.app/Contents/Resources/app/lib/preload.js init.ts:206
init.ts:207 Error: Cannot find module 'loglevel'
Require stack:
- /Users/kiki/APP-darwin-x64/APP.app/Contents/Resources/app/lib/preload.js
at Module._resolveFilename (internal/modules/cjs/loader.js:798)
at Function../lib/common/reset-search-paths.ts.Module._resolveFilename (reset-search-paths.ts:40)
at Module._load (internal/modules/cjs/loader.js:691)
at Module._load (electron/js2c/asar.js:717)
at Function.Module._load (electron/js2c/asar.js:717)
at Module.require (internal/modules/cjs/loader.js:853)
at require (internal/modules/cjs/helpers.js:74)
at Object.<anonymous> (/Users/kiki/APP-darwin-x64/APP.app/Contents/Resources/app/lib/preload.js:21)
at Object.<anonymous> (/Users/kiki/APP-darwin-x64/APP.app/Contents/Resources/app/lib/preload.js:68)
at Module._compile (internal/modules/cjs/loader.js:968)
(anonymous) @ init.ts:207
/Users/kiki/APP-darwin-x64/APP.app/Contents/Resources/app/lib/preload.js:46 Uncaught ReferenceError: Cannot access 'INJECT_JS_PATH' before initialization
at injectScripts (/Users/kiki/APP-darwin-x64/APP.app/Contents/Resources/app/lib/preload.js:46)
at HTMLDocument.<anonymous> (/Users/kiki/APP-darwin-x64/APP.app/Contents/Resources/app/lib/preload.js:16)
Verbs log without errors:
log.txt
Test site is in the log.
Also found this: LINK . But I don't know what that means.

Same issue here when trying to inject JS
Same issue here when trying to inject JS
I believe I am also having the same issue with nativefier version 8.0.4 on Linux when trying to inject javascript. A very similar error appears in console, and javascript that worked fine in older versions of nativefier no longer does anything.
This is also affecting me on Linux with 8.0.6. 8.0.5 also suffers from it, though 8.0.0 does not. I'm short on time atm, but I took a quick pass at a diff and no cause jumped out at me, so I've downgraded for now: npm install -g [email protected]. Happy to test a fix if one comes along.
Thanks contributors for this indispensable tool! :blue_heart:
This is also affecting me on Linux with 8.0.6. 8.0.5 also suffers from it, though 8.0.0 does not. I'm short on time atm, but I took a quick pass at a diff and no cause jumped out at me, so I've downgraded for now:
npm install -g [email protected]. Happy to test a fix if one comes along.Thanks contributors for this indispensable tool!
Can confirm that 8.0.0 allows javascript to be injected without issue.
For those who are new to the nativefier like me, there is an issue with installation of 8.0.0-3. More info on how to fix it here: https://github.com/jiahaog/nativefier/releases .
Also confirming 8.0.0 throws no error.
I went back and forward on this in versions now to test few things.
Its funny what I found out. On 8.0.0 preload is included as well as desired js.
But, I'm new to this and first thing I used is latest 8.0.6 and I had OSX notifications called from webpage threw app, as well as cookies setup (they worked only until app is quieted) . But none of those works on 8.0.0 where preload works and injection...
And it would be really nice to have both :)
It looks like the issue was introduced in 8.0.4. 8.0.3 works for me. 8.0.4 does not.
Created PR which should resolve the issue: https://github.com/jiahaog/nativefier/pull/950
馃憢 everybody. This is fixed and released in 8.0.7 . Thanks for the chat and ideas!
Most helpful comment
This is also affecting me on Linux with 8.0.6. 8.0.5 also suffers from it, though 8.0.0 does not. I'm short on time atm, but I took a quick pass at a diff and no cause jumped out at me, so I've downgraded for now:
npm install -g [email protected]. Happy to test a fix if one comes along.Thanks contributors for this indispensable tool! :blue_heart: