架构师_程序员_码农网

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 5710|回复: 0

什么是npm?npm是什么?

[复制链接]
发表于 2016-12-14 10:36:03 | 显示全部楼层 |阅读模式
npm makes it easy for JavaScript developers to share and reuse code, and it makes it easy to update the code that you're sharing.


If you've been working with Javascript for a while, you might have heard of npm: npm makes it easy for Javascript developers to share the code that they've created to solve particular problems, and for other developers to reuse that code in their own applications.

Once you're depending on this code from other developers, npm makes it really easy to check to see if they've made any updates to it, and to download those updates when they're made.

These bits of reusable code are called packages, or sometimes modules. A package is just a directory with one or more files in it, that also has a file called "package.json" with some metadata about this package. A typical application, such as a website, will depend on dozens or hundreds of packages. These packages are often small. The general idea is that you create a small building block which solves one problem and solves it well. This makes it possible for you to compose larger, custom solutions out of these small, shared building blocks.

There's lots of benefits to this. It makes it possible for your team to draw on expertise outside of your organization by bringing in packages from people who have focused on particular problem areas. But even if you don't reuse code from people outside of your organization, using this kind of module based approach can actually help your team work together better, and can also make it possible to reuse code across projects.

You can find packages to help you build your application by browsing the npm website. When you're browsing the website, you'll find different kinds of packages. You'll find lots of node modules. npm started as the node package manager, so you'll find lots of modules which can be used on the server side. There are also lots of packages which add commands for you to use in the command line. And at this point you can find a number of packages which can be used in the browser, on the front end.

So now that you have an idea of what npm can do, let's talk about how it works. When people talk about npm, they can be talking about one of three things. They could be talking about the website, which we've just been looking at. Or they could be talking about the registry, which is a big database of information about packages that people are sharing. Or the third thing they could be talking about is the client: when a developer decides to share their code, they use the npm client which is installed on their computer to publish that code up to the registry. And once there's an entry for this package in the registry, then other developers can use their npm clients to install the package from the registry. The entry in the registry for this package is also reflected on the website, where there's a page dedicated to this new package.

So that's what npm is. It's a way to reuse code from other developers, and also a way to share your code with them, and it makes it easy to manage the different versions of code.


npm使JavaScript开发人员可以轻松地共享和重用代码,并且可以轻松更新您共享的代码。


如果你已经使用了Javascript一段时间,你可能已经听说过npm:npm让Javascript开发人员很容易共享他们创建的代码来解决特定的问题,而其他开发人员可以在他们的自己的应用程序。

一旦你依赖于其他开发人员的这个代码,npm使它很容易检查他们是否有任何更新,并下载这些更新时,它们。

这些位的可重用代码称为包,有时称为模块。包只是一个包含一个或多个文件的目录,还有一个名为“package.json”的文件,其中包含有关此包的一些元数据。典型的应用程序,如网站,将取决于几十个或数百个软件包。这些包通常很小。一般的想法是,你创建一个小的构建块,解决一个问题,解决它。这使得您可以在这些小的共享构建块中构建更大的自定义解决方案。

这有很多好处。它使您的团队有可能利用在您的组织以外的专业人员引入来自专注于特定问题领域的人的包。但是即使你不重复你组织以外的人的代码,使用这种基于模块的方法实际上可以帮助你的团队更好地工作,也可以跨项目重复使用代码。

您可以通过浏览npm网站找到帮助您构建应用程序的软件包。当您浏览网站时,您会发现不同类型的软件包。你会发现很多节点模块。 npm作为节点包管理器启动,所以你会发现很多模块可以在服务器端使用。还有很多包添加命令以供您在命令行中使用。在这一点上,你可以找到一些可以在浏览器中使用的软件包,在前端。

所以现在你有一个想法的npm可以做什么,让我们谈谈它如何工作。当人们谈论npm时,他们可以谈论三件事之一。他们可能在谈论我们刚刚看过的网站。或者他们可能在谈论注册表,这是一个大数据库的人们正在分享的包的信息。或者他们可以谈论的第三件事是客户端:当开发人员决定共享他们的代码时,他们使用安装在他们的计算机上的npm客户端将该代码发布到注册表。一旦这个包在注册表中有一个条目,那么其他开发人员可以使用他们的npm客户端从注册表安装包。这个包的注册表中的条目也反映在网站上,其中有一个专门用于这个新包的页面。

这就是npm是什么。它是一种重用来自其他开发人员的代码的方法,也是一种与他们共享代码的方法,它使得管理不同版本的代码变得更加容易。





上一篇:linux设置DNS服务器
下一篇:node.js使用package.json初始化
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

免责声明:
码农网所发布的一切软件、编程资料或者文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:help@itsvse.com

QQ|手机版|小黑屋|架构师 ( 鲁ICP备14021824号-2 )|网站地图

GMT+8, 2024-3-28 20:52

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表