Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
699 views
in Technique[技术] by (71.8m points)

javascript - 你如何通过终端运行JavaScript脚本?(How do you run JavaScript script through the Terminal?)

For instance, if you were to run a Python script you would type python filename.py or if you wanted to run a C program make filename then ./ filename .

(例如,如果你要运行Python脚本,你可以输入python filename.py,或者如果你想运行一个C程序make filename然后是./ filename 。)

How do you do this with .js files?

(你如何用.js文件做到这一点?)

  ask by BLUC translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Another answer would be the NodeJS!

(另一个答案是NodeJS!)

Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications.

(Node.js是一个基于Chrome JavaScript运行时的平台,可轻松构建快速,可扩展的网络应用程序。)

Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.

(Node.js使用事件驱动的非阻塞I / O模型,使其轻量级和高效,非常适合在分布式设备上运行的数据密集型实时应用程序。)

Using terminal you will be able to start it using node command.

(使用终端,您将能够使用node命令启动它。)

$ node
> 2 + 4
6
> 

Note : If you want to exit just type

(注意 :如果要退出,只需键入)

.exit

You can also run a JavaScript file like this:

(您还可以运行如下的JavaScript文件:)

node file.js

? Install it NOW ?

(?现在安装?)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...