Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Core node modules work in app but not in tests #148

eccentric-j opened this issue Feb 4, 2019 · 2 comments

[BUG]: Core node modules work in app but not in tests #148

eccentric-j opened this issue Feb 4, 2019 · 2 comments


Copy link

@eccentric-j eccentric-j commented Feb 4, 2019


I am able to access core node modules in dev build but not in my tests.


Created to minimally reproduce the problem

  1. Run git clone
  2. Run cd minirepro-fig-test-deps
  3. Run lein fig:build
  4. Run node target/node/dev/dev-main.js
  5. You should see output similar to:
    Loaded main script
    Running main fn
    #js [".gitignore" "" "dev.cljs.edn" "figwheel-main.edn" "node_modules" "package-lock.json" "package.json" "project.clj" "src" "target" "test" "test.cljs.edn"]
  6. It worked. Now run lein fig:test


  • Tests pass or fail
  • Exit code should reflect test status


  • Tests never run
  • Error is thrown:
    No such namespace: fs, could not locate fs.cljs, fs.cljc, or JavaScript source providing "fs" in file minirepro-fig-test-deps/src/minirepro_fig_test_deps/core.cljs {:tag :cljs/analysis-error}
        at cljs.analyzer$error.invokeStatic(analyzer.cljc:706)
        at cljs.analyzer$error.invoke(analyzer.cljc:702)
        at cljs.analyzer$error.invokeStatic(analyzer.cljc:704)
        at cljs.analyzer$error.invoke(analyzer.cljc:702)
        at cljs.analyzer$analyze_deps.invokeStatic(analyzer.cljc:2159)
        at cljs.analyzer$analyze_deps.invoke(analyzer.cljc:2133)
        at cljs.analyzer$ns_side_effects.invokeStatic(analyzer.cljc:3509)
        at cljs.analyzer$ns_side_effects.invoke(analyzer.cljc:3504)
        at cljs.analyzer$analyze_STAR_$fn__2534.invoke(analyzer.cljc:3629)
        at clojure.lang.PersistentVector.reduce(
        at clojure.core$reduce.invokeStatic(core.clj:6827)
        at clojure.core$reduce.invoke(core.clj:6810)
        at cljs.analyzer$analyze_STAR_.invokeStatic(analyzer.cljc:3629)
        at cljs.analyzer$analyze_STAR_.invoke(analyzer.cljc:3619)
        at cljs.analyzer$analyze.invokeStatic(analyzer.cljc:3649)
        at cljs.analyzer$analyze.invoke(analyzer.cljc:3631)
        at cljs.compiler$emit_source.invokeStatic(compiler.cljc:1390)
        at cljs.compiler$emit_source.invoke(compiler.cljc:1369)
        at cljs.compiler$compile_file_STAR_$fn__3696.invoke(compiler.cljc:1471)
        at cljs.compiler$with_core_cljs.invokeStatic(compiler.cljc:1289)
        at cljs.compiler$with_core_cljs.invoke(compiler.cljc:1278)
        at cljs.compiler$compile_file_STAR_.invokeStatic(compiler.cljc:1455)
        at cljs.compiler$compile_file_STAR_.invoke(compiler.cljc:1448)
        at cljs.compiler$compile_file$fn__3727.invoke(compiler.cljc:1553)
        ... 74 more


  • Am I importing core node modules incorrectly?
  • Why does it work with npm deps but not built-in node modules?
  • If the answer is simple, should I make a PR to update the docs?



^{:watch-dirs ["test" "src"]
  :auto-testing true}
{:main minirepro-fig-test-deps.core
 :npm-deps     {"ws" "6.1.3"}
 :install-deps true
 :target :nodejs}


  ;; use an alternative landing page for the tests so that we don't
  ;; launch the application
  :open-url "http://[[server-hostname]]:[[server-port]]/test.html"

  ;; uncomment to launch tests in a headless environment
  ;; you will have to figure out the path to chrome on your system
  ;; :launch-js ["/Applications/Google Chrome" "--headless" "--disable-gpu" "--repl" :open-url]
{:main minirepro-fig-test-deps.test-runner
 :target :nodejs}
Copy link

@bhauman bhauman commented Apr 10, 2019

Yes your test.cljs.edn file is not correct.

You at least need to remove the :open-url param as it makes no sense in this context. I think the :open-url is causing this to run in the Browser and thats why you are getting that error.

Copy link

@nenadalm nenadalm commented Jul 29, 2019

Hi. I have the same issue with simpler reproduction (ClojureScript script running on nodejs using built-in module).

Project setup


{:paths ["src"]
 :deps {org.clojure/clojurescript {:mvn/version "1.10.520"}
        com.bhauman/figwheel-main {:mvn/version "0.2.3"}}}


{:main app.core
 :target :nodejs}


(ns app.core
   [path :as path]))

(defn -main [& args]
  (println (.join path "/first" "second")))

(set! *main-cli-fn* -main)


Compiling and then running the script runs just fine:

$ clj -m figwheel.main -bo dev
$ node target/node/dev/dev-main.js 

Running script using -m option fails on missing node module:

$ clj -m figwheel.main -co dev.cljs.edn -m app.core
2019-07-29 10:37:52.354:INFO::main: Logging initialized @8217ms to org.eclipse.jetty.util.log.StdErrLog
[Figwheel] Compiling build dev to "target/node/dev/dev-main.js"
[Figwheel] Failed to compile build dev in 1.751 seconds.
[Figwheel:WARNING] Compile Exception   /var/www/html/nenadalm/contrib/figwheel-main-issues/148/src/app/core.cljs   line:3  column:5

  No such namespace: path, could not locate path.cljs, path.cljc, or JavaScript source providing "path" in file /var/www/html/nenadalm/contrib/figwheel-main-issues/148/src/app/core.cljs

  1  (ns app.core
  2    (:require
  3     [path :as path]))
  5  (defn -main [& args]
  6    (println (.join path "/first" "second")))
  8  (set! *main-cli-fn* -main)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants