什么是 NPM,我为什么需要它? [英] What is NPM and why do I need it?

查看:73
本文介绍了什么是 NPM,我为什么需要它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去,我用记事本做一些网站,所以我们必须创建一个文件夹 TREE 并在其中放入一个 .htm 文件,以及一些包含 Javascript、css 之类的文件夹......

In the past, I made some websites with notepad for example, so we must create a folder TREE and put into it a .htm file, and some folderS with stuff like Javascript, css ...

也许我不明白 NPM 真正带来了什么,因为它似乎在做同样的事情,但它是自动化的......只是这样吗?

Maybe I don't understand what NPM really brings, because It seems to do the same thing but automated it ... is it just that ?

例如,为什么不直接解压框架(例如 Bootstrap 或 Kube)而不使用 NPM,然后准备好可用的文件夹?

For example, why not just unpack a frameworks (e.g. Bootstrap or Kube) without use of NPM and so have folders ready to use ?

请帮助我理解,因为我对所有这些东西都快疯了......

Help me to understand please because I'm near the crazy state with all this stuff ...

推荐答案

npm 是 Node.js 的包管理器,拥有数百个数以千计的包裹.尽管它确实会创建一些目录结构/组织,但这不是主要目的.

npm is a package manager for Node.js with hundreds of thousands of packages. Although it does create some of your directory structure/organization, this is not the main purpose.

正如您所提到的,主要目标是自动化依赖项和包管理.这意味着您可以在 package.json指定项目的所有依赖项> 文件,然后任何时候您(或其他任何人)需要开始使用您的项目,他们只需运行 npm install 并立即安装所有依赖项.除此之外,还可以指定您的项目所依赖的版本,以防止更新破坏您的项目.

The main goal, as you touched upon, is automated dependency and package management. This means that you can specify all of your project's dependencies inside your package.json file, then any time you (or anyone else) needs to get started with your project they can just run npm install and immediately have all of the dependencies installed. On top of this, it is also possible to specify what versions your project depends upon to prevent updates from breaking your project.

绝对可以手动下载您的库,将它们复制到正确的目录中,然后以这种方式使用它们.但是,随着您的项目(和依赖项列表)的增长,这将很快变得耗时且混乱.它还使协作和共享您的项目变得更加困难.

It is definitely possible to manually download your libraries, copy them into the correct directories, and use them that way. However, as your project (and list of dependencies) grows, this will quickly become time-consuming and messy. It also makes collaborating and sharing your project that much more difficult.

希望这能让大家更清楚 npm 的目的是什么.作为 Javascript 开发人员(客户端和服务器端),npm 是我工作流程中不可或缺的工具.

Hopefully this makes it more clear what the purpose of npm is. As a Javascript developer (both client-side and server-side), npm is an indispensable tool in my workflow.

这篇关于什么是 NPM,我为什么需要它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆