What exactly is node. js?
One of the reasons Chrome is faster than other browsers is because Chrome has something called V8 that can efficiently parse JavaScript.
V8 compiles javascript into native machine code (ia-32,x86-64,arm,mips, etc.) and uses methods such as inline caching to improve performance. According to legend, with the help of V8, JavaScript runs almost as efficiently as the binary program. However,node. JS has more features than V8, such as direct access to the file system , processing of binary data , and so on. So we can write all kinds of local tools with JavaScript syntax. The most famous of these are the front-end automation building tools : Webpack, Gulp, Grunt ... Then stop by the end of the story.
A long time ago in a galaxy far, far away ...
The concept of the front-end is nothing more than HTML, CSS, JavaScript, then the style and interaction of the page is not now so complex, so only need to complete the basic style display and data manipulation is good.
As time went by ...
A variety of complex pages appeared successively, even the Angular, React such a large project. To increase the load speed of Web pages, the front end had to put all the files together and confuse compression to save traffic and requests before they were released.
The above mentioned three tools, any one can meet this demand. When configured, we simply execute a grunt build at the command line, we can stitch up and confuse the various pieces of code files, and even compress the image, and execute a gulp serve to preview the effect of our writing by simply opening a small server locally.
A good helper for node. JS: NPM
In fact, node. JS programmers rarely input the node command, and they use the most command of NPM. So what's a NPM thing? This again has to mention two concepts: package, Dependency .
Remember the "Compress image using Grunt build " just mentioned? In fact, the compression of this step is not Grunt do, but a tool called imagemin do. If you want to install it, you can download the corresponding code from GITHUB and then put down the code for the 36 projects that this guy relies on: Gulp-imagemin, Node-atlas, Cropshop ... And then the dependency of these projects also ...
What about the pit daddy!
Fortunately we have NPM, just need again npm install -g imagemin
, NPM will read the imagemin dependency from the specified source (the default is the official source), and then read the dependencies inside these dependencies ... Build an installation sequence with topology ordering, and then automatically fix everything you need, if you have a command with it -g
, it's a global installation, which is as natural as the native command-line tool. Of course you can also delete them by a single order.
A tool is a package. The full name of NPM is Node package Manager.
Excerpt from: Https://blog.coding.net/blog/nodejs-webhook
First knowledge of node. js