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

相关推荐
●VON3 分钟前
从模型到价值:MLOps 工程体系全景解析
人工智能·学习·制造·von
好奇龙猫4 分钟前
【人工智能学习-AI-MIT公开课第 18. 表示:分類、軌跡、過渡】
学习
XiaoYu20028 分钟前
第11章 LangChain
前端·javascript·langchain
霉运全滚蛋好运围着转36 分钟前
启动 Taro 4 项目报错:Error: The specified module could not be found.
前端
cxxcode39 分钟前
前端模块化发展
前端
不务正业的前端学徒43 分钟前
docker+nginx部署
前端
不务正业的前端学徒1 小时前
webpack/vite配置
前端
hhcccchh1 小时前
学习vue第八天 Vue3 模板语法和内置指令 - 简单入门
前端·vue.js·学习
yyf198905251 小时前
Vue 框架相关中文文献
前端·javascript·vue.js
粥里有勺糖1 小时前
开发一个美观的 VitePress 图片预览插件
前端·vue.js·vitepress