#[Solved] Getting started instructions do not work

19 messages · Page 1 of 1 (latest)

spark sand
#

FYI, following the Getting Started instructions https://www.electronforge.io/ do not work. I've tried with both yarn and npm following the instructions exactly:

yarn create electron-app my-app
cd my-app
yarn start

Environment:
node v17.9.0
yarn 3.2.4
"electron": "21.2.3"
"@electron-forge/cli": "^6.0.3",

Note I also attempted to run yarn install as suggested by the below error and it did not change the outcome.
Error:

An unhandled rejection has occurred inside Forge:
Error: Cannot find the package "electron". Perhaps you need to run "yarn install" in "C:\git\my-app"?

Electron Forge was terminated. Location:
at getElectronPackageJSONPath (C:\git\my-app\.yarn\cache\@electron-forge-core-utils-npm-6.0.3-55d7a41980-49f767ae8b.zip\node_modules\@electron-forge\core-utils\dist\electron-version.js:77:15)
    at async Object.getElectronModulePath (C:\git\my-app\.yarn\cache\@electron-forge-core-utils-npm-6.0.3-55d7a41980-49f767ae8b.zip\node_modules\@electron-forge\core-utils\dist\electron-version.js:87:29)
    at async Object.locateElectronExecutable [as default] (C:\git\my-app\.yarn\cache\@electron-forge-core-npm-6.0.3-b401caf829-1e772cdce3.zip\node_modules\@electron-forge\core\dist\util\electron-executable.js:12:30)
    at async forgeSpawn (C:\git\my-app\.yarn\cache\@electron-forge-core-npm-6.0.3-b401caf829-1e772cdce3.zip\node_modules\@electron-forge\core\dist\api\start.js:114:32)
    at async forgeSpawnWrapper (C:\git\my-app\.yarn\cache\@electron-forge-core-npm-6.0.3-b401caf829-1e772cdce3.zip\node_modules\@electron-forge\core\dist\api\start.js:150:25)
    at async Object._default [as default] (C:\git\my-app\.yarn\cache\@electron-forge-core-npm-6.0.3-b401caf829-1e772cdce3.zip\node_modules\@electron-forge\core\dist\api\start.js:181:22)
    at async C:\git\my-app\.yarn\cache\@electron-forge-cli-npm-6.0.3-033f125ec2-3bd599c183.zip\node_modules\@electron-forge\cli\dist\electron-forge-start.js:48:21
hazy spear
#

Hmm the team usually uses yarn 1, not really sure if using yarn 3 makes things more complicated

#

What do you get if you just use npm instead?

spark sand
#

with npm i get the error 'electron-forge' is not recognized as an internal or external command, operable program or batch file.

#

I think this is because npm won't run command line programs without npx preceeding the command whereas yarn will

#

Also the app still has a .yarn and yarn.lock file in it even though i installed it with npm fyi

#

okay I got it working with npm

#

Had to do a few extra steps though:

#
  1. Change package.json scripts from electron-forge to npx electron-forge
#
  1. Had to run npm i --save-dev electron-prebuilt-compile
#

I would recommend adding these instructions to the getting starting section for npm

hazy spear
#

Had to run npm i --save-dev electron-prebuilt-compile
that sounds like the wrong workaround

#

@spark sand can you start from scratch with the following command with the NODE_INSTALLER=npm environment variable?

npx clear-npx-cache
npm init electron-app@latest my-app
#

and maybe post your entire log here rather than just the error line!

spark sand
#

Clearing the cache worked

#

Thank you

#

Is there a way to mark this as solved?

#

[Solved] Getting started instructions do not work

hazy spear
#

Closing the thread helps 🙂