如何在OS X上使用jsc运行JavaScript? [英] How to run JavaScript using jsc on OS X?

查看:193
本文介绍了如何在OS X上使用jsc运行JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我试图找到某种方法通过终端运行我的JavaScript程序时,我得到了 .提到的runload命令可以执行外部JavaScript文件.帮我怎么做.我正在尝试运行存储在本地系统中的JavaScript程序.

I got this when I was trying to find some way to run my JavaScript programs through terminal. The run and load command mentioned can execute external JavaScript files. Help me how to do this. I am trying to run JavaScript programs which are store locally on my system.

编辑:我正在尝试用JavaScript解决Euler Q10项目.这就是我要在NodeJ或JSC中运行的程序.在运行Node和JSC中的JavaScript文件时,我需要帮助. 任何示例都将非常有帮助.

EDIT: I am trying to solve Project Euler Q10 in JavaScript. So this is the program that I want to run in NodeJs or JSC. I need help in running the JavaScript files in Node and JSC. Any example will be really helpful.

谢谢大家.

推荐答案

这篇文章的补充,JSC居住在

/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc

,默认情况下不在外壳PATH中.您可以使用

and is not in the shell PATH by default. You can fix that with

ln -s /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc /usr/local/bin

jsc将文件名作为参数.您可以使用

jsc takes filenames as arguments. You could run a file named demo.js with

jsc demo.js

请注意,您必须在脚本中使用debug()而不是常规的console.log()来查看任何输出.

Note that you'll have to use debug() instead of the conventional console.log() in your script to see any output.

这篇关于如何在OS X上使用jsc运行JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆