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

npm install -g create-vue

npm install -g nvm

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

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

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.

最近更新

  1. TCP协议是安全的吗?

    2024-02-20 07:28:04       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-20 07:28:04       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-20 07:28:04       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-20 07:28:04       20 阅读

热门阅读

  1. mysql远程连接

    2024-02-20 07:28:04       29 阅读
  2. Redis & RabbitMQ

    2024-02-20 07:28:04       27 阅读
  3. 平台组成-用户管理

    2024-02-20 07:28:04       32 阅读
  4. 上传(图片)文件的功能实现

    2024-02-20 07:28:04       30 阅读
  5. 基于单片机的智能宠物喂食器设计

    2024-02-20 07:28:04       28 阅读
  6. 单例模式的几种实现方式

    2024-02-20 07:28:04       26 阅读