Closed nyxynyx closed 3 years ago
--target electron
should work here (not shim the fs
module).
@mischnic Tried using --target electron
:
% parcel -p 3000 index.html --out-dir build --target electron
✨ Built in 4.58s.
but it is stuck at this stage and never returns the line:
Server running at http://localhost:3000
Is there something wrong with the syntax used? Any way to increase the verbosity of this command to have a better glimpse of what may have gone wrong?
Turns out that the dev server is not started with --target electron
...
@mischnic That makes sense now!
From cli.js
I cannot figure out how to start the server when using --target electron
. Is it possible to do this? Thanks!
I have the exact same issue and would be very happy if somebody could help.
@mischnic @nyxynyx @Achder I have the same issue as you guys too!
Any solution to this problem so far?
I would also like to know the solution, --target electron stops the server being started
I switched to electron-webpack.
I am in the same position as everyone else here. --target electron prevents server from starting and the electron app never opens. It will build successfully, but when I open the generated dmg file, its just a white blank page. Any help would be appreciated.
I managed to get a working version (without --target electron)
https://github.com/sketchbuch/electron-parcel-react-typescript
I'm using that repo now as the basis of a new elctron app. I had to create a type for the FS functions I wanted exposed in the renderer (via preload script).
Same for me
@sketchbuch your boilerplate doesn't fix problem.
just tried to import electron
in react app
It fixed my issue which was accessing fs in the renderer. My needs are quite simple - I only need access to FS functions as I use electron as a wrapper for a web app - I'm not making something as complex as atom.
Did you try exposing the ipcrenderer in preload.js and adding a type??? Apparently you shouldn't do this anyway, but you can. What may be better is using context bridge in the preload script.
https://www.electronjs.org/docs/api/context-bridge
See https://stackoverflow.com/questions/45148110/how-to-add-a-callback-to-ipc-renderer-send (answer from tobey blaber), another example is here. https://gist.github.com/ccnokes/6cde9022cef33106f7360af8f671a6c1
Probably I should expose fs functions via the context bridge too. I shall look into this but it seems now to access main stuff in renderer you now have to use the preload script. My last electron app I made could access fs in the renderer without using a preload script - I guess they changed stuff to make it more secure
import electron in from 'electron' in renderer will not work. You need to expose what you want in the preload script
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.
I'm having this issue with parcel v2 and the electron-renderer
target :/
🐛 bug report
Getting the errors
fs.existsSync is not a function
andCannot statically evaluate fs argument"
when running an app based onelectron-react-parcel-boilerplate
and usingredux-beacon-electron
🎛 Configuration (.babelrc, package.json, cli command)
CLI Command:
yarn start
package.json
🤔 Expected Behavior
The electron should load with no errors.
😯 Current Behavior
When starting the Electron app based on the
electron-react-parcel-boilerplate
and usingredux-beacon-electron
, an error appears in the Electron JS console:and an error appears in the Terminal where
yarn start
was run:💁 Possible Solution
🔦 Context
Attempt 1
Thinking that this may be solved by specifying the
node
orelectron
target, I ranyarn start
again after modifying theyarn run
script fromto
and
but things appear to be worse. The electron app no longer pops up after building, and nothing is listening to localhost:3000, so react server probably didnt start.
Attempt 2
Tried setting
nodeIntegration: true
when creatingBrowserWindow
, but nothing changed.Part of electron.js (usually named
main.js
)💻 Code Sample
GITHUB REPO:
https://github.com/nyxynyx/electron-react-parcel-boilerplate-problem
Adding the following code to my redux store file
store.js
will cause the mentioned errors to appear:Reference:
redux-beacon-electron
README.md🌍 Your Environment