johndyer24 / electron-cra-example Goto Github PK
View Code? Open in Web Editor NEWExample of how to structure an Electron app with Create React App
Example of how to structure an Electron app with Create React App
I have a complete Electron/React project and I'm using your electron-cra-example as a guide to packaging my project with electron-builder. I followed your instructions on modifying main.js
and placing it into the project-name/electron
directory, as well as moving the appropriate files to project-name/src/react
and project-name/src/shared
. Notably, package.json
is updated with the appropriate lines, including"main": "electron/main.js"
.
The problem is that when I run npm run start-electron
I receive an error that implies the node_modules directory cannot be found. It seems confused about main.js
running from project-name/electron
. Do you have any thoughts on how I might fix this? I tested your repo code and confirmed it works just fine on my machine. This is clearly an issue with how I'm adapting your project to my own. Thanks for making such a nice guide.
> set NODE_ENV=development&&electron .
App threw an error during load
Error: Cannot find module '/Users/name/EB/project/electron/node_modules/electron'
Require stack:
- /Users/name/EB/project/electron/main.js
- /Users/name/EB/project/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js
-
at Module._resolveFilename (internal/modules/cjs/loader.js:961:15)
at Function.o._resolveFilename (electron/js2c/browser_init.js:257:921)
at Module._load (internal/modules/cjs/loader.js:844:27)
at Function.Module._load (electron/js2c/asar.js:769:28)
at Module.require (internal/modules/cjs/loader.js:1023:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/Users/name/EB/project/electron/main.js:22:13)
at Module._compile (internal/modules/cjs/loader.js:1145:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1166:10)
at Module.load (internal/modules/cjs/loader.js:981:32)
^X^C/Users/name/EB/project/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron exited with signal SIGINT
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] electron-start: `set NODE_ENV=development&&electron .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] electron-start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/name/.npm/_logs/2021-01-25T02_20_03_836Z-debug.log
I'm getting this error
The syntax of the command is incorrect.
Started : Saturday, February 29, 2020 21:32:03
Source : C:\ReactApps\111\electron-cra-example\src\shared
Dest : C:\ReactApps\111\electron-cra-example\build\src\shared\
Files : *.*
Options : . /S /DCOPY:DA /COPY:DAT /R:1000000 /W:30
New Dir 1 C:\ReactApps\111\electron-cra-example\src\shared\
100% New File 72 constants.js
Total Copied Skipped Mismatch FAILED Extras
Dirs : 1 1 0 0 0 0
Files : 1 1 0 0 0 0
Bytes : 72 72 0 0 0 0
Times : 0:00:00 0:00:00 0:00:00 0:00:00
Speed : 72000 Bytes/sec.
Speed : 4.119 MegaBytes/min.
Ended : Saturday, February 29, 2020 21:32:03
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build-electron-win: mkdir build/src && robocopy electron build/electron /S & robocopy src/shared build/src/shared /S
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build-electron-win script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ashto\AppData\Roaming\npm-cache_logs\2020-03-01T03_32_03_310Z-debug.log
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.