#Electron and Yarn

9 messages · Page 1 of 1 (latest)

charred crest
#

Greetings. I've built an electron app, and did all my CLI interactions through npm. Thanks to wanting to see if electron-builder might be right for me, and it preferring to install via yarn, I tried to rebuild the project with yarn as a base rather than npm. I created an empty directory, ran:
yarn init -2
yarn add --dev electron
I noticed first that contrary to the documentation on the electron tutorial, running yarn init did not, as npm does, bring up an interactive set of prompts to pre-populate your package.json, so I copied values over from the npm version of my app in another folder, then I laboriously copied the rest of the working directory over, excepting the node_modules folder.
I then tried to add the one other package I was using:
yarn add electron-is-dev
It was time to test:
yarn start
And I got an error that it could not find electron-is-dev.
If I comment out the lines in my app that care about electron-is-dev, the app works. But I can't figure out why it can't find the package. It got added to package.json, I see it in yarn.lock, I see it in .yarn/cache, but the actual application dies with an error if I try to use it.
I do not know if this is more of a yarn question or an electron question, but perhaps someone here will have some insight into
what I might have done wrong.
Thank you!

thorn meadow
#

Hello. Switching from npm to yarn should not have been so complicated. You just have to delete your node_modules (just in case), delete your package-lock.json and then run yarn to install the dependencies listed in your package.json. I don't think initing a new project was necessary.

#

At least, I just had to do that when I decided to use yarn on my own project.

charred crest
#

Thank you; I'll make a fresh copy of my npm-ed version and try that. I may have been misled by documentation talking about making sure you get Modern Yarn rather than Classic Yarn, because my first attempt involved typing "yarn init -2" in the directory for my project, and that blew away the project.json. So probably, since the project exists, running "init" is a trap. But that's what led me to this overly complicated way of going about things...

thorn meadow
#

I'm not sure to know what is modern yarn or classic yarn but in any case I think it should not be related to your project since yarn is installed on your computer

charred crest
#

Ok, for the curious:
Attempt 1- delete node_modules and package-lock.json, run "yarn" where yarn is v1.22.19 (which is "Classic" yarn, I believe).
This appeared to work, though running my app does now spit this in the console:
[7144:1004/131949.053:ERROR:backend_impl.cc(2019)] Invalid file version or magic

#

But it seemed to work.

#

I then made another copy of the original and tried upgrading yarn to the latest with
yarn set version stable
which set it to 3.2.3
I then deleted node_modules and package-lock.json, ran yarn, and then tried to run the app.

#

I unfortunately have to present the error as an image, as it popped up as a modal window over powershell: