Node.js和npm哪个词选择“包”或“模块”?(Node.js and npm which word to choose “package” or “module”?)

编程入门 行业动态 更新时间:2024-10-28 08:19:17
Node.js和npm哪个词选择“包”或“模块”?(Node.js and npm which word to choose “package” or “module”?)

我很困惑npm是一个包管理器,但是Node.js有模块。 所以当你安装或创建自己的...... erhmm,模块,包? 选择哪个词而不是另一个?

I am confused npm is a package manager, but Node.js has modules. So when you install or create your own... erhmm, module, package? Which word to choose over another and when?

最满意答案

看一下docs http://nodejs.org/docs/latest/api/modules.html :

在节点中,文件和模块是一一对应的。

另一方面,package是一个包含特殊package.json文件的文件夹。 该文件告诉解释器如何在require(folder);时加载模块require(folder); 。 换句话说,package是模块的集合。

Have a look at docs http://nodejs.org/docs/latest/api/modules.html :

In Node, files and modules are in one-to-one correspondence.

On the other hand package is a folder with a special package.json file in it. That file tells the interpreter how to load modules when you do require(folder);. In other words package is a collection of modules.

更多推荐

本文发布于:2023-08-07 03:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1460852.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模块   词选   js   npm   Node

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!