[英]Why JavaScript frontend framework is needed for Node.js to run?
When we talk about JavaScript vanilla it's frontend programming language;当我们谈论 JavaScript vanilla 时,它是前端编程语言; It needs a webserver like IIS, Apache or nginx etc to deliver the content to a client when requested.
它需要一个像 IIS、Apache 或 nginx 等的网络服务器来在请求时将内容传送到客户端。 After that, JavaScript runs on client browser, but every video or article I found said we need to install node.js to make this work.
之后,JavaScript 在客户端浏览器上运行,但我发现的每个视频或文章都说我们需要安装 node.js 才能使其工作。 What I know about node.js is its a runtime environment to make JavaScript work outside the browser;
我对 node.js 的了解是它的运行时环境使 JavaScript 在浏览器之外工作; like for a backend api or regular desktop application.
就像后端 api 或常规桌面应用程序。
Here is my question: Why do we need to use Node.js if our target is to deploy a frontend webapp that's gonna run on the client browser?这是我的问题:如果我们的目标是部署将在客户端浏览器上运行的前端 web 应用程序,为什么我们需要使用 Node.js?
You don't have to install and use Node to make frontend applications, but it can help a lot, especially in large projects.你不必安装和使用节点,使前端应用程序,但它可以有很大的帮助,尤其是在大项目。 The main reason it's used is so that script-writers can easily install, use, and update external packages via NPM.
使用它的主要原因是脚本编写者可以通过 NPM 轻松安装、使用和更新外部包。 For a few examples:
举几个例子:
And so on.等等。 Organizing an environment for these sorts of things would be very difficult without NPM (which depends on Node).
如果没有 NPM(这取决于 Node),为这些事情组织环境将非常困难。
None if it is necessary , but many find that it can make the development process much easier.没有必要,但许多人发现它可以使开发过程更容易。
In the process of creating files for the client to consume, if you want to do anything more elaborate than write plain raw .js
, .html
, .css
files, you'll need something extra - which is most often done via NPM.在创建供客户端使用的文件的过程中,如果您想做比编写纯原始
.js
、 .html
、 .css
文件更复杂的事情,您将需要一些额外的东西 - 这通常是通过 NPM 完成的。
It's only for extra support during development, and ease of installing libraries.它只是为了在开发过程中提供额外的支持,以及易于安装库。 almost like an extra IDE / helpful editor
几乎就像一个额外的 IDE/有用的编辑器
for example you might want to see changes you make on your HTML and frontend javascript code, without having to refresh the preview browser.例如,您可能希望查看对 HTML 和前端 JavaScript 代码所做的更改,而无需刷新预览浏览器。 node will provide a package that does that...
节点将提供一个包来做到这一点......
it also helps install and use libraries easier.它还有助于更轻松地安装和使用库。 for example, if you want to add a library like bootstrap to your frontend, rather than searching around and downloading the files... but if you use node project, you can simply use
npm install bootstrap
that will automatically download the lastest version from the right source.例如,如果你想在你的前端添加一个像 bootstrap 这样的库,而不是四处搜索并下载文件……但是如果你使用 node 项目,你可以简单地使用
npm install bootstrap
,它会自动从正确的来源。
that's all就这样
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.