The title of the question says it all. There are many articles on this, but in a clear and starter way, what is NPM in fact and what does it do? Like the Node?
What do they contribute to website building?
The title of the question says it all. There are many articles on this, but in a clear and starter way, what is NPM in fact and what does it do? Like the Node?
What do they contribute to website building?
NodeJs is a runtime that allows you to run JavaScript code outside browsers. Can be used inside other applications or even alone. It is an environment that functions as a virtual machine for executing JS scripts.
If you know PHP, think of it as both the language and its execution environment. It is a counterpoint to C # which is the language and .Net is the execution environment. NodeJs is just the environment. His language is JavaScript. So think of NodeJs itself as the whole environment package.
Another comparison is the JRE, that is the Java package that you are required to install on your computer because of some software that needs and was done in Java (for example, to access banking websites). >
It is widely used on the server side to meet the demands of web applications. There are some advantages to it, there are also disadvantages. But in general it's just an option. Some choose because they have a need, others adopt because JavaScript is the only language they know and do not want to use another that might be more appropriate on the server side. Usually it runs without server. Something that is common today in other technologies, but it has the merit of demonstrating that this is not only feasible but also desirable in many situations.
One of the advantages is a good event engine and non-blocking asynchronous execution . So it is known to give great scalability. Something other technologies can too.
Its success is due not only to allowing JS that people were already accustomed to, the fact that technologies generally had difficulty handling parallel operations and the sequential did not serve well. Especially PHP that is heavily used on the server side is not good at this. People saw him as salvation.It does not scale well for multiple processors (kernels).
It has a more extensive API than JS has in a browser, it can access database and files, for example. And of course if it does not run in the browser it does not make sense to have the APIs specific to it.
He currently uses the Google-engineered JS V8 engine for Chrome that was the fastest at the time NodeJs were created, but the fastest is a transient feature. As far as I know, nothing prevents a day from being changed, although it is doubtful that it will happen, unless for some serious reason, there would be compatibility problems.
What do they contribute to website building?
If you think of websites as the client side NodeJs does not contribute anything. By chance it can be used on the server side, but it is no different from using another environment / language.
NPM (Node Package Manager) is just a management pack for JS code modules to install next to NodeJs and be able to use in your applications, or even your applications that need to be included next to the Node.
Roughly it is an installer taking care of the dependencies avoiding having to keep them next to your application and take care of the updates. What does not always work as expected . It is also a module repository.
Node.js
is a platform built on the JavaScript
engine of Chrome to easily build fast and scalable network applications. Node.js
uses a non-blocking event-driven I / O model that makes it lightweight and efficient, ideal for real-time applications with intense data exchange across distributed devices. Its goal is to help programmers create high-scalability applications (such as a web server) with codes capable of handling tens of thousands of concurrent connections on a single physical machine.
How does it work?
The Node runs in% w /% V8 VM. JavaScript
on the server side may be a new concept for everyone who has worked exclusively with JavaScript on the client side. The V8 JavaScript engine is the engine Google uses with its Chrome browser. Few people think about what actually happens with JavaScript
on the client side. The JavaScript
engine actually interprets the code and executes it. With V8 Google created an ultra-fast interpreter written in JavaScript
, with another unique aspect: you can download the engine and incorporate it into any desired application. This is not restricted in running in a browser. So Node currently uses the% V8 engine written by Google and proposes that it be used on the server.
NPM is the reduced name of Node Package Manager (Node Package Manager). NPM is two things: First, and most importantly, it is an online repository for publishing open source projects for C++
; second, it is a command line utility that interacts with this online repository, which helps with package installation, version management, and dependency management ..
From the version JavaScript
0.5.x the NPM became integrated with the Node.js
installer and this simplified the life of the developers, since before that there were several package managers for Node.js
.
It also maintains an online NPM repository that is also maintained by Joyent, currently it contains more than 30,000 open-source modules.
What do you do?
When you are going to develop an application and decide to use a library, for example, the Coalan McMahon asynchronous library, you only need to use the Node.js
command, and the specific module will be installed in the current directory within the Node.js
. Once your npm install async
folder is installed, you will be able to use ./node_modules/
in it as if they were internal modules of your project.
Reference: NodeBR