NPM tutorials on the web focus on how to install, configure, and use NPM, but don’t tell newcomers why to use NPM. That’s what I’m going to talk about today.

This article is aimed at “new people who don’t know much about NPM”.

community

Programmers have an ancient culture of community:

Community means: people who share a common occupation or interest, organize themselves together and collaborate by sharing information and resources. Participants in virtual communities often discuss related topics online or visit certain websites.

Front-end programmers also have communities, and GitHub is probably the largest front-end community in the world. The front end comes via GitHub

  1. Sharing source code (online repository)
  2. List of issues discussed
  3. Collect learning resources and frequently-visited websites (such as my collection of high-quality Chinese front-end blogs)


One of the best things about joining a community is that you can use code that others have contributed, and you can contribute code to others.

To share code

How does the front end share code?

In GitHub’s pre-github days, the front end was sharing code via a web address

For example, if you want to use jQuery, you can click on the link provided on the jQuery website to download jQuery and use it on your own website


After GItHub emerged, some people in the community also used GItHub download function:

trouble

As a website relies on more and more code, programmers find it troublesome:

  1. Download jQuery from the jQuery website
  2. Go to the BootStrap website to download BootStrap
  3. Go to Underscore’s official website to download Underscore


Some programmers can’t stand it. Isaac Z. Schlueter (Isaaz), a programmer with three virtues, has a solution: use a tool to bring all the code together and manage it.


This tool is NPM, which he wrote in JavaScript (running on Node.js). It stands for Node Package Manager

Specific steps

The idea of NPM goes something like this:

1. Buy a server as a registry where all the code that needs to be shared is stored

Use NPM Publish to submit code to Registry and name jQuery, Bootstrap, and Underscore respectively.

3. If others in the community want to use the code, they write jquery, bootstrap, and underscore into package.json and then run NPM install and NPM will download the code for them

4. The downloaded code appears in the node_modules directory and can be used freely.

The code that can be used is called a package, which is where NPM gets its name: Node Package Manager.

The development of

Isaaz informs jQuery author John Resig, will he say yes? I don’t know about that, do I?

John Resig will only consider using NPM if everyone in the community thinks it is a treasure.

So how did NPM catch on?

The growth of NPM goes hand in hand with the growth of Node.js.

Node.js was written by Ryan Dahl, an American programmer working in Germany. He wrote Node.js, but node.js lacked a package manager, so he hit it off with the authors of NPM, and eventually NPM was built into Node.js.

As you all know, Node.js took off.

With the popularity of Node.js, people started to use NPM to share JS code, so the author of jQuery released 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.

subsequent

Node.js is currently being developed by Joyent, the company Ryan Dahl was working for at the time. Ryan Dahl has now moved on to AI and machine learning, and he has handed over the maintenance of Node.js to Isaaz. (Should I also study AI and machine learning, coach?)

After maintaining the registry for a period of time, Isaaz resigned and established a company dedicated to maintaining the NPM Registry. The company name is NPM Co., LTD… Who says open source can’t make money

The power of community

If you look at the development of the front end, it’s always someone in the community who releases a piece of code that affects the front end for years. Like jQuery, like Node.js, like NPM. (This is also true in other languages.)

So the power of community is enormous.


Welcome into the group and I discuss technology, stamp this scan code plus wechat into the programmer sharing exchange group.

The author of this article hunren Gu – fang fang, without consent prohibit reprint, reprint please contact me and add the copyright statement and link to this article.