简体   繁体   English

所有 node.js 模块都是服务器端的吗?

[英]Are all node.js modules server-side?

除非使用browserify和类似工具打包,否则是否有前端节点模块或全部都是服务器端?

Node.js modules are designed to be used with Node.js. Node.js 模块旨在与 Node.js 一起使用。

You might run Node.js as a server side environment.您可以将 Node.js 作为服务器端环境运行。 You might run it as a command line program.您可以将它作为命令行程序运行。 You might run it as an HTTP client in its own right.您可以将其作为 HTTP 客户端运行。

Node.js does not run inside a browser. Node.js 不在浏览器中运行。 Node.js modules are not generally designed for use embedded in a webpage using <script> elements. Node.js 模块通常不是为使用<script>元素嵌入网页而设计的。

It is possible to write a hybrid JavaScript file that can function both as a Node.js module and as a script in a webpage … but there isn't often a good reason to do so.可以编写一个混合 JavaScript 文件,它既可以用作 Node.js 模块,也可以用作网页中的脚本……但通常没有充分的理由这样做。 (I've done it once: To write a client for a particular webservice that I wanted to use in a browser and in a Node.js program). (我曾经做过一次:为我想在浏览器和 Node.js 程序中使用的特定 Web 服务编写客户端)。

Browserify can convert some Node.js modules so they can run in a browser. Browserify 可以转换一些Node.js 模块,以便它们可以在浏览器中运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM