专注、坚持

从 npm 说开去...(草稿)

2023.02.02 by kingcos

概念摸底

Node.js

根据维基百科:

Node.js is a cross-platform, open-source server environment that can run on Windows, Linux, Unix, macOS, and more. Node.js is a back-end JavaScript runtime environment, runs on the V8 JavaScript Engine, and executes JavaScript code outside a web browser.

Node.js 是一个跨平台、开源的服务器环境,可以运行在 Windows、Linux、Unix、macOS 以及更多平台中。Node.js 是一个后端 JavaScript 运行时环境,运行在 V8 JavaScript 引擎,并在网页浏览器之后执行 JavaScript 代码。

CommonJS

根据维基百科:

CommonJS is a project with the goal to establish conventions on the module ecosystem for JavaScript outside of the web browser. The primary reason for its creation was a major lack of commonly accepted forms of JavaScript module units which could be reusable in environments different from that provided by conventional web browsers running JavaScript scripts (e.g. web servers or native desktop applications).

CommonJS 是一个旨在为网页浏览器之外的 JavaScript 建立模块生态系统约定的项目。其产生的主要原因是缺乏被普遍接受的 JavaScript 模块单元,这些模块单元可以在不同于运行 JavaScript 脚本的传统网页浏览器提供的环境中重用(例如网页服务器或本地桌面应用程序)。

npm

根据维基百科:

npm (originally short for Node Package Manager) is a package manager for the JavaScript programming language maintained by npm, Inc. npm is the default package manager for the JavaScript runtime environment Node.js. It consists of a command line client, also called npm, and an online database of public and paid-for private packages, called the npm registry. The registry is accessed via the client, and the available packages can be browsed and searched via the npm website.

npm(最初是 Node Package Manager 的缩写)是一个由 npm, Inc 维护的 JavaScript 编程语言包管理器。npm 是 JavaScript 运行时环境 Node.js 的默认包管理器。其由一个命令行客户端(又称 npm),以及一个包含公开和付费使用私有包的线上数据库(又称 npm 注册表)组成。该注册表可以通过客户端访问,也可通过 npm 网页浏览和搜索可用的包。

Node.js 和 npm 均诞生于 2009 年,但 npm 诞生更晚一些。目前,npm 已经和 Node.js 捆绑,下载和安装 Node.js 时也会安装 npm。

node_modules

package.json

参考