Node.js中的模块和包之间的区别? [英] Difference between a module and a package in Node.js?

查看:195
本文介绍了Node.js中的模块和包之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Node.js的新手. Node.js中的包"和模块"有什么区别?

I am new to Node.js. What is the difference between a "package" and a "module" in Node.js?

推荐答案

模块是用于Node.js.请参阅以下API摘录:

Modules are libraries for Node.js. See the below excerpt from the API:

Node.js有一个简单的模块加载系统.在Node.js中,文件和模块 一对一对应.

Node.js has a simple module loading system. In Node.js, files and modules are in one-to-one correspondence.

模块示例:

  • Circle.js
  • Rectangle.js
  • Square.js

包是将一个或多个模块(库)组合在一起(或打包在一起).这些通常由其他软件包或您自己的项目使用. Node.js使用包管理器,您可以在其中找到并安装成千上万的包.

A package is one or more modules (libraries) grouped (or packaged) together. These are commonly used by other packages or a project of your own. Node.js uses a package manager, where you can find and install thousands of packages.

包装示例:

Shapes             <- Package name
  - Circle.js      <-
  - Rectangle.js   <- Modules that belong to the Shapes package
  - Square.js      <-

基本上,您可以安装软件包Shapes,并可以访问圆",矩形"和正方形"模块.

Essentially, you could install the package, Shapes, and have access to the Circle, Rectangle, and Square modules.

这篇关于Node.js中的模块和包之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆