本文介绍了使用Rhino从命令行执行编译的ClojureScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我知道ClojureScript可以在JavaScript REPL中执行,也可以编译成JavaScript,然后在浏览器中运行。我找不到一个方法来使用它在服务器端与Rhino。这里是我的思维方式,我有一个简单的源文件: (ns simple.hello) (printlnHello,world) 我编译为 hello .js 。我尝试运行 java -jar js.jar out / goog / base.js out / goog / deps.js out / hello.js 没有发生任何事情。 解决方案这对我有用: src / app.js: (ns simple.app) (ns hello)(defn ^:export greet [n] (print(strHellon))) World) 要编译: cljsc src'{:optimizations:advanced}'> app-prod.js 然后,使用Rhino运行: java -jar js.jar app-prod.js 输出:Hello World 希望有帮助! I understand ClojureScript can be executed within a JavaScript REPL or it can be compiled into JavaScript, then run in a browser. I couldn't find a way to use it on the server side with Rhino. Here is my way of thinking, I have a simple source file:(ns simple.hello)(println "Hello, world")I compile it to hello.js. I try to runjava -jar js.jar out/goog/base.js out/goog/deps.js out/hello.jsNothing happens. How can I make it work, or is only Node.js supported on the command line? 解决方案 This works for me:src/app.js: (ns simple.app)(ns hello)(defn ^:export greet [n] (print (str "Hello " n)))(greet "World")To compile: cljsc src '{:optimizations :advanced}' > app-prod.jsThen, to run with Rhino: java -jar js.jar app-prod.jsOutput: Hello WorldHope that helps! 这篇关于使用Rhino从命令行执行编译的ClojureScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!