【每天学习一点点 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.

相关推荐
lhh_qrsly1 天前
HTTP / HTTPS / MQTT / MQTTs(嵌入式学习版)
学习·http·https
剪刀石头布啊1 天前
vue-react为何要虚拟dom
前端
剪刀石头布啊1 天前
ahooks常用的一些库,我们使用一下
前端
剪刀石头布啊1 天前
从git更新本地提交记录到更新已经推送到远端记录
前端
Flynt1 天前
axios 被投毒半年后,我把 npm 的"安全防线"实测了一遍:最信任的 SHA512 是安慰剂
前端·npm·node.js
excel1 天前
Base62 和 Base64 有什么区别?
前端
风骏时光牛马1 天前
大模型底层架构与AI源码深度剖析
前端
掘金挖土1 天前
前端手摸手跑路之 AI 应用开发(九)
前端·后端
中文呀2 天前
三维 GIS 离线缓存实战:逆向 CesiumOfflineCache,并亲手为它补上"自动更新"能力
前端