Skip to content

How to run electron app from source #1288

Closed

Description

@dpsutton

Hi. I'm trying to get a local dev setup going to explore the codebase. I'm able to get a repl in CIDER for the :app profile. However, I'm not sure how to get the electron version running. In the package.json file i see "dev-electron-app" under scripts. When I ran this, i got an error that electron-forge wasn't installed. After installing that globally, I'm now an error:

SHADOW import error /Users/dan/projects/clojure/logseq/.shadow-cljs/builds/electron/dev/out/cljs-runtime/electron.utils.js
App threw an error during load
Error: Cannot find module 'electron-log'
Require stack:
- /Users/dan/projects/clojure/logseq/static/electron.js
- /Users/dan/projects/clojure/logseq/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js
-
    at Module._resolveFilename (internal/modules/cjs/loader.js:972:15)
    at Function.n._resolveFilename (electron/js2c/browser_init.js:249:921)
    at Module._load (internal/modules/cjs/loader.js:848:27)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12738)
    at Module.require (internal/modules/cjs/loader.js:1032:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at /Users/dan/projects/clojure/logseq/.shadow-cljs/builds/electron/dev/out/cljs-runtime/electron/utils.cljs:8:1
    at global.SHADOW_IMPORT (/Users/dan/projects/clojure/logseq/static/electron.js:64:44)
    at /Users/dan/projects/clojure/logseq/static/electron.js:1723:1
    at Object.<anonymous> (/Users/dan/projects/clojure/logseq/static/electron.js:1731:3)
shadow-cljs - #16 ready!

I'm wondering if I'm doing the correct thing or if there's an easier way that already has all of the necessary dev requirements installed. Thanks!

ps, if you're interested in a .dir-locals file that makes development in emacs easier i'm including the following:

((nil . ((cider-preferred-build-tool . "clojure-cli")
         (cider-jack-in-nrepl-middlewares . ("cider.nrepl/cider-middleware" "shadow.cljs.devtools.server.nrepl/middleware"))
         (cider-clojure-cli-aliases . "cljs:test"))))

Then, just jack in (not clojurescript actually, just regular clj).

user> (require '[shadow.cljs.devtools.server :as server])
nil
user> (server/start!)
shadow-cljs - HTTP server available at http://localhost:3002
shadow-cljs - server version: 2.11.14 running at http://localhost:9631
:shadow.cljs.devtools.server/started
user> (require '[shadow.cljs.devtools.api :as shadow])
nil
user> (shadow/watch :app)
[:app] Configuring build.
[:app] Compiling ...
WARNING: format already refers to: #'clojure.core/format in namespace: frontend.util, being replaced by: #'frontend.util/format
[:app] Build completed. (686 files, 335 compiled, 0 warnings, 24.07s)
:watching
user> (shadow/nrepl-select :app)
To quit, type: :cljs/quit
[:selected :app]
cljs.user> (js/alert "hi")

included for any emacs users who might want to get a cljs repl up easily.

Activity

  1. tiensonqin commented on Feb 7, 2021

    @tiensonqin
    Contributor

    @dpsutton Hey, it seems that yarn dev-electron-app which runs gulp electron doesn't run yarn in the /static folder.
    Otherwise, it should install both electron-forge and electron-log.

    Currently, I think you can go to the /static folder and run yarn to give it a try, lmk whether it works for you, thanks!

  2. tiensonqin commented on Feb 24, 2021

    @tiensonqin
    Contributor

    @dpsutton Sorry to bother, do you still have the issue with the setup?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions