At the time of writing it was 12'21, a bonus tip for Webpack updated on 01'22
1) First and most common classic way of doing so :
package.json
"..." : "...",
"main" : "main.js",
"scripts" : {
"start" : "electron .",
}
"..." : "..."
Secondly, within current working directory (cwd) run the following on terminal :
npm run start
How main works have a read this practical article of mine
NOTE : test, start, restart, and stop – are npm recognizable commands , so alias of run is optional , although for the sake of idiomatic convention I used a full term of npm run start
2) Alternatively we can forget package.json config by simple doing :
npx electron main.js
EXPLANATION : npx vs. npm have a few contextual cases in terms how it works , but herein it serves as executable for
./node_modules/.bin/electron .
which was not added to PATH on my Win10 machine as I tend to install Electron locally, this is side effect of such behaviour I had & will have to use npx over npm as shown above to avoid some of package.json configs
BONUS TIP : similar approach to above can be applied to locally installed webpack compiling process for
./node_modules/.bin/webpack
within cwd runningnpx webpack
Top comments (0)