Fuzhou website construction only needs 1,000 yuan including domain name space, details 18558752805

  • What does npm do ?. Understanding npm

Fuzhou Website Construction > Web News > Web Design >

The online npm tutorials are mainly about how to install, configure, and use npm, but rarely tell newcomers "What does npm do?" "Why use npm?" Today I will talk about this topic. The target audience of this article is "newcomers who don't know much about npm", old drivers please bypass.


Programmers have a community culture since ancient times. Community means: People who share a common career or interest, spontaneously organize together and collaborate through sharing information and resources. Participants in virtual communities often discuss related topics online or visit certain websites. There is also a community of front-end programmers, and the largest front-end community in the world should be GitHub. The front end uses GitHub to share the source code (online code repository), discuss issues (Issue list), collect learning resources and frequently visited websites (such as the high-quality Chinese front-end blogs I collected). One of the biggest benefits of joining the community is that you can use code contributed by others, and you can also contribute code for others to use.

Share code

How does the front end share code? In an era when GitHub has not yet emerged, the front end is to share code through URLs. For example, if you want to use jQuery, then you can click on the link provided on the jQuery website to download jQuery and use it on your own website. After the rise of GItHub, some people in the community also used GitHub's download feature.


When a project depends on more and more code, programmers find it a troublesome thing:
1. Go to jQuery official website and download jQuery
2. Go to BootStrap's official website to download BootStrap
3. Go to Underscore official website and download Underscore
Some programmers can't stand the bird. Isaac Z. Schlueter (hereinafter referred to as Isaaz), a programmer with three virtues, gives a solution: centralize the code together with a tool to manage it! This tool is npm, written in JavaScript (running on Node.js), which is called Node Package Manager.

The idea of npm is roughly this:
1. Buy a server as a code repository (repository), put all the code that needs to be shared in it
2. Email the authors of jQuery, Bootstrap, and Underscore to submit the code to the repository using npm publish and name them jquery, bootstrap, and underscore (note the case)
3. If other people in the community want to use this code, write jquery, bootstrap and underscore into package.json, then run npm install, npm will help them download the code
4. The downloaded code appears in the node_modules directory and can be used at will.

The code that can be used is called a "package". This is where the npm name comes from: Node Package Manager.

development of

Isaaz informs jQuery author John Resig, will he agree? This is not necessarily true, right? John Resig will consider using npm only when people in the community think "npm is a treasure."

So how is npm hot?
The development of npm is complementary to the development of node.js. node.js was written by Ryan Dahl, an American programmer based in Germany. He wrote node.js, but node.js lacks a package manager, so he and the author of npm hit it off in a hurry and warmed up. Finally, node.js has npm built in.

As everyone knows later, node.js is on fire. With the popularity of node.js, everyone started to share JS code with npm, so jQuery authors also published jQuery to npm. So now, you can use npm install jquery to download the jQuery code. Using npm to share code is now standard on the front end.

Follow up

node.js is currently being developed by joyent, the company where Ryan Dahl was at the time. Ryan Dahl has now researched AI and machine learning, and he delegates the maintenance of node.js to Isaaz. After Isaaz maintained it for a while, he resigned, and established a company to specifically maintain npm's repository. The company's name is npm Co., Ltd ... Who said that open source can't make money? ? ?

The power of the community

Looking back at the development history of the front end, you will find that it is usually someone in the community who has released a code that ultimately affects the direction of the front end in the next few years. Such as jQuery, such as node.js, such as npm, in fact, other languages are also like this, so the power of the community is huge.

Author: Keller7
Source: The copyright of Jianshu belongs to the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
Scan QR code to share on WeChat

Copyright © 2014-2019 Fuzhou website production