[英]Can node.js be used as a framework for running arbitrary server-side Javascript in web applications?
Can node.js be used as a general framework for running server-side Javascript specifically for web applications, totally unrelated to it's non-blocking and asynchrouns I/O functionality? node.js可以用作运行服务器端Javascript的通用框架,专门用于Web应用程序,完全与它的非阻塞和异步路由I / O功能无关吗? Specifically I want to know if I can run arbitrary Javascript on the (web) server without using the other node.js functionality.
具体来说,我想知道我是否可以在(web)服务器上运行任意Javascript而不使用其他node.js功能。
Yes, it's possible to use node.js for command-line applications, for example: 是的,可以将node.js用于命令行应用程序,例如:
$ cat hello.js
console.log('Hello world!');
$ node hello.js
Hello world!
It's essentially just like any scripting language in this regard. 它基本上就像这方面的任何脚本语言一样。
Yes. 是。 There are many web frameworks built on node.
在节点上构建了许多Web框架。 The most known is Express based on Connect .
最着名的是基于Connect的 Express 。
Connect takes the familiar concepts of Ruby's Rack and applies it to the asynchronous world of node
Connect采用Ruby的Rack熟悉的概念,并将其应用于节点的异步世界
Express: 表达:
High performance, high class web development for Node.js
Node.js的高性能,高级Web开发
But I/O - web request for example - depends on node's asynchronous and non-blocking functionality. 但I / O(例如Web请求)取决于节点的异步和非阻塞功能。
In the end, "node.js" is inside a v8 runtime environment, so you can of course execute arbitrary Javascript code. 最后,“node.js”位于v8运行时环境中,因此您当然可以执行任意Javascript代码。 However, due to it's singe-processed design, it may be difficult to run multiple CPU-intensive computations in parallel.
但是,由于采用单处理设计,可能难以并行运行多个CPU密集型计算。 That is not what node.js has been designed for.
这不是node.js的设计目标。
Yes. 是。 What is important to understand is that Node is a set of I/O bindings (file, TCP, etc) that layers on top of Chrome's V8 JavaScript interpreter.
重要的是要理解的是Node是一组I / O绑定(文件,TCP等),它们位于Chrome的V8 JavaScript解释器之上。
You can use Node in two modes: 您可以在两种模式下使用Node:
Execute a known JavaScript file 执行已知的JavaScript文件
$ node some_script.js $ node some_script.js
Execute in REPL (interactive mode) 在REPL中执行(交互模式)
$ node $ node
var i = 1;
var i = 1;
console.log(i);的console.log(ⅰ);
11
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.