【每天学习一点点 day05】工程化 重新认识npm 01_关于npm

之前对于npm的使用一直停留在 npm install 上,对于npm这个工具其他更多有用有趣的功能还没有使用过,那么今天借助这个机会,重新学习一下npm,为接下来构建自己的repo铺路。

官方文档:About npm | npm Docs (npmjs.com)

1. npm由哪些构成

首先,npm不仅仅是一个用于执行命令的软件/命令行工具,而是一个宏观上的node包管理者/管理平台,npm即 ++node package manager++。。

npm install 中的npm 实际上使用的是npm 下的npm-cli命令行工具

++npm主要由以下三部分构成:++

  • the website, 即主页,主要用来搜索包或者管理自己的包,类似于mvnrepository

Use the website(https://npmjs.com) to discover packages, set up profiles, and manage other aspects of your npm experience.
For example, you can set up organizations to manage access to public or private packages.

  • npm-cli,包含 npm install、npm init 等命令

The CLI runs from a terminal, and is how most developers interact with npm.

  • the registry,即npm包的仓库,用来存放代码包

The registry is a large public database of JavaScript software and the meta-information surrounding it.

2. 用npm做什么

以下内容来自npm 中文文档 (nodejs.cn)

2.1. 下载工具 or 为自己的项目添加依赖(也是一般开发程序员常用的功能)

  • 下载您可以立即使用的独立工具。 (这个就是我们常用的npm install)

Download standalone tools you can use right away.

bash 复制代码
npm install -g create-vue

npm install -g nvm

...
  • 为您的应用程序调整代码包,或按原样合并包。

Adapt packages of code for your apps, or incorporate packages as they are.

bash 复制代码
npm install axios --save

npm install sass --save-dev

2.2. 免下载工具直接使用,例如一些脚手架等等

一般脚手架会使用npx,从而省略npm install -g下载到本地

  • 使用 npx 运行包而不下载。

Run packages without downloading using npx.

2.3. 成为openSourcerDeveloper,npm包开发与共享

  • 随时随地与任何 npm 用户共享代码。

Share code with any npm user, anywhere.

  • 将代码限制为特定的开发人员。

Restrict code to specific developers.

  • 创建组织以协调包维护、编码和开发人员。

Create organizations to coordinate package maintenance, coding, and developers.

  • 通过使用组织形成虚拟团队。

Form virtual teams by using organizations.

2.4. npm包管理&更新&发布

  • 管理多个版本的代码和代码依赖项。

Manage multiple versions of code and code dependencies.

  • 更新底层代码时轻松更新应用程序。

Update applications easily when underlying code is updated.

2.5. DealWithBugs 集思广益,开源精神

  • 发现解决同一个难题的多种方法。

Discover multiple ways to solve the same puzzle.

  • 寻找正在处理类似问题和项目的其他开发人员。

Find other developers who are working on similar problems and projects.

相关推荐
dear_bi_MyOnly4 小时前
【MyBatis 操作数据库】
java·数据库·学习·mybatis·学习方法
一只小菜鸡..5 小时前
南京大学 操作系统 (JYY) 学习笔记:从 UNIX 到 Linux 与庞大的应用生态
笔记·学习·unix
东方小月5 小时前
从零开发一个 Coding Agent(四):使用状态机校验大模型事件流
前端·人工智能·后端
Csvn5 小时前
🧩 ESM vs CJS 混用的 7 个「天坑」——从 TypeScript 编译到 Node 与浏览器
前端
Csvn6 小时前
🎯 Web 性能 API 集合:Performance Observer 的 5 个冷门妙用
前端
MartinYeung56 小时前
[论文学习]迈向自主医疗人工智能智能体:MIRA系统深度分析
人工智能·学习
Csvn6 小时前
深入 React 闭包陷阱:从根源上理解并根治 stale closure
前端
whyfail6 小时前
前端学 Spring Boot(8):接口为什么越用越慢?
前端·spring boot·后端
用户059540174467 小时前
LangChain 记忆测试踩坑实录:这两个坑让我排查了 4 小时
前端·css
程序员黑豆7 小时前
鸿蒙应用开发:@Monitor 装饰器使用教程
前端·harmonyos