So I've come to the conclusion that the REPL and CIDER do not pick up any
of the NodeJS namespaces. I have to build the project and run it with node
instead. Not sure exactly why this is the case....
On Monday, September 25, 2017 at 7:56:16 AM UTC-4, Jonathon McKitrick wrote:
>
> Update: it turns out several of the dependencies of mysql had to be
> imported at the project level. At least, that's what I did to get past the
> dependency errors. Now I'm stuck here:
>
> path.js:7
> throw new TypeError('Path must be a string. Received ' +
> inspect(path));
> ^
>
> TypeError: Path must be a string. Received { './support/isBuffer.js':
> './support/isBufferBrowser.js' }
> at assertPath (path.js:7:11)
> at Object.join (path.js:1211:7)
> at Deps.<anonymous> ([eval]:115:32)
> at emitOne (events.js:96:13)
> at Deps.emit (events.js:188:7)
> at
> /Users/devmbp42/arc/check-templates/node_modules/@cljs-oss/module-deps/index.js:338:18
>
> It looks like I got past the dependency issues, but I'm not sure where to
> go from here....
>
> On Monday, September 25, 2017 at 7:16:20 AM UTC-4, Jonathon McKitrick
> wrote:
>>
>> Here's what I have so far:
>>
>> (defproject foo "0.1.0-SNAPSHOT"
>> :description "FIXME"
>>
>> :dependencies [[org.clojure/clojure "1.8.0"]
>> [org.clojure/clojurescript "1.9.908"]
>> [com.cemerick/piggieback "0.2.2"]]
>>
>> :plugins [[lein-cljsbuild "1.1.7"]
>> [lein-ancient "0.6.12"]]
>> :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
>>
>> :source-paths ["src"]
>>
>> :cljsbuild
>> {:builds
>> [{:source-paths ["src"]
>> :compiler
>> {:target :nodejs
>> :output-to "check_templates.js"
>> :optimizations :none
>> :npm-deps {:mysql "2.14.1"}
>> :install-deps true
>> :main check-templates.core
>> :parallel-build true}}]})
>>
>> and
>>
>> (ns check-templates.core
>> (:require [cljs.nodejs :as nodejs]
>> #_[mysql :as sql]))
>>
>> (nodejs/enable-util-print!)
>>
>> (defn -main [& args]
>> (.log js/console "Hello world")
>> (println "Hello world"))
>>
>> (set! *main-cli-fn* -main)
>>
>> I run `lein cljsbuild once` and I get the node_modules directory
>> populated with dependencies.
>> I can run `lein repl` and then use piggieback to get to the CLJS repl.
>> But I seem unable to get the mysql dependency imported.
>>
>> If I enable the `require` form to import mysql in the source file and
>> then start the repl and require the project namespace, I get this error:
>>
>> events.js:160
>> throw er; // Unhandled 'error' event
>> ^
>>
>> Error: Can't resolve 'url' in
>> '/Users/devmbp42/arc/check-templates/node_modules/mysql/lib'
>> at onError
>> (/Users/devmbp42/arc/check-templates/node_modules/enhanced-resolve/lib/Resolver.js:61:15)
>>
>> So it's finding the modules and attempting to load them. But I don't know
>> enough about NodeJS to understand exactly what is broken or how to fix it.
>>
>>
>> On Friday, September 22, 2017 at 1:33:07 PM UTC-4, Jonathon McKitrick
>> wrote:
>>>
>>> Hi all,
>>>
>>> I'm slowly but surely weaseling Clojure and Clojurescript into our
>>> company's codebase. I'm tasked with a script which will read from a MySQL
>>> database and generate a very simple report.
>>>
>>> So far, I have a NodeJS REPL project up and running, but I'm not quite
>>> sure how to get Node's MySQL library into the project and namespace. Any
>>> thoughts?
>>>
>>>
>>>
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/clojurescript.