javascript 我什么时候应该在独立的 node.js 上使用 express.js
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27824859/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
When should I use express.js over a standalone node.js
提问by Mitro
Node.jsis a javascript environment
Node.js是一个 javascript 环境
Expressis a framework
Express是一个框架
What is a software framework?for Node.js?
什么是软件框架?对于 Node.js?
Why and when is it useful to use Express framework over Node.js standalone?
为什么以及何时在 Node.js 上独立使用 Express 框架有用?
What I mean is that, is this framework just a set of ready functions and modules that makes it easier to write codes from scratch?
我的意思是,这个框架是否只是一组现成的功能和模块,可以更轻松地从头开始编写代码?
I'm asking this because I found lots of tutorials and guides on NodeJS with Express, but just a few on standalone NodeJs.
我问这个是因为我发现了很多关于 NodeJS 和 Express 的教程和指南,但只有一些关于独立 NodeJs 的。
采纳答案by frajk
As you suspect, Express.js just makes it easier to write a Node.js webapp. You could build anything you could with Express.js without it.
正如您所怀疑的那样,Express.js 只是让编写 Node.js Web 应用程序变得更容易。没有它,你可以用 Express.js 构建任何你可以构建的东西。
Many factors go into whether to use a given framework or not, such as available support, documentation, future development, does it fit needs of project, etc. Express.js is the most popular Node.js web application framework, but that doesn't mean it should automatically be your choice. Here's a link to an article which you may find interesting, and contains alternatives to Express.js which may be worth exploring - https://scotch.io/bar-talk/the-future-of-expressjs-and-alternatives
许多因素会影响是否使用给定的框架,例如可用的支持、文档、未来的开发、它是否适合项目的需求等。 Express.js 是最受欢迎的 Node.js Web 应用程序框架,但事实并非如此。这意味着它应该自动成为您的选择。这是一篇您可能会感兴趣的文章的链接,其中包含可能值得探索的 Express.js 替代方案 - https://scotch.io/bar-talk/the-future-of-expressjs-and-alternatives
You can also check out this tutorial on writing a Node.js application without a framework - http://www.nodebeginner.org/
您还可以查看有关在没有框架的情况下编写 Node.js 应用程序的教程 - http://www.nodebeginner.org/
回答by NeiL
The reason it is famous because Easy learning curve.There are lot of inbuilt, third-party middleware compatible with it. It overall provides complete structure in clean syntax. And yes you are right ,it is just a set of ready functions and modules that can be used easier than writing code from 0. It saves time. There lot of resources on nodejs with express.
之所以出名,是因为学习曲线简单。有很多内置的第三方中间件与之兼容。它总体上以简洁的语法提供了完整的结构。是的,你是对的,它只是一组现成的函数和模块,比从 0 开始编写代码更容易使用。它节省了时间。nodejs 上有很多带有 express 的资源。
But The same functionality can be done without expressjs which requires research.
但是没有需要研究的 expressjs 也可以完成相同的功能。