bhauman / lein-figwheel

Figwheel builds your ClojureScript code and hot loads it into the browser as you are coding!
Eclipse Public License 1.0
2.88k stars 209 forks source link

npm-deps not working #576

Closed okilimnik closed 7 years ago

okilimnik commented 7 years ago

I'll copy it from slack:

okilimnik [11:11 AM] I can not require moment from npm-depth: $moment is not a function. Clojurescript 1.9.671

(ns horago.screens.drawer.profile.profile
  (:require [moment]))

(fn [date] (dispatch [:user (assoc @user :dob
                     (.format (moment date) server-df) )]))

Could be it's just a react native issue but I don't understand how it can differ from simple cljs dependencies which just works I've tried lein prod-build and all is working! Seems like it is a figwheel issue

I use [lein-figwheel "0.5.11"]

compiler options:

{:id "ios"
                                             :source-paths ["src" "env/dev"]
                                             :figwheel     true
                                             :compiler     {:output-to     "target/ios/not-used.js"
                                                            :main          "env.ios.main"
                                                            :output-dir    "target/ios"
                                                            :optimizations :none
                                                            :npm-deps {:moment "2.18.1"}}}

Could be you should update clojurescript version in order to use a new build api to compile npm dependencies?

esseswann commented 7 years ago

I have been testing the same way as you but I've stumbled upon :npm-deps not working on Windows because it couldn't call npm properly. On Ubuntu it works well, it installs the dependencies through npm automatically but I have the same problem with moment not being a function in my tests.

bhauman commented 7 years ago

AFAIK this is a ClojureScript issue only figwheel just passes compiler options forward to ClojureScript.

LeaveNhA commented 6 years ago

I start figwheel and it doesn't work. But I run "lein clean; lein cljsbuild once dev;" it is working. There is nothing special in profile. It's strange.

wnr commented 6 years ago

I had a similar issue and it got resolved by manually deleting ´resources/public/js/compiled´ and then running figwheel again.

maackle commented 6 years ago

I am shocked. I spent 3 hours trying to troubleshoot :npm-deps not working (typical message: Uncaught Error: Undefined nameToPath for {{package-name}}. Manually deleting resources/public/js/compiled as @wnr suggested fixed it for me!

wnr commented 6 years ago

Great that it worked out for you. Here are some extra actions that may help with similar issues (for future readers):

pesterhazy commented 6 years ago

Ran into this as well in a project when switching branches. lein clean fixes it.