node.js – What is NPM and Node?

Question:

The question title says it all. There are many articles about this, but in a clear and for beginners way, what is NPM in fact and what does it do? Like Node?

What do you contribute in building websites?

Answer:

NodeJs

NodeJs is a runtime that allows JavaScript code to run outside of browsers. It can be used within other applications or even alone. It is an environment that works as a virtual machine for running JS scripts .

If you know PHP, think that it is 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 that NodeJs itself is the whole environment package.

Making another comparison is the JRE, that is, that Java package that you are obliged to install on your computer because of some software you need and was made in Java (accessing bank websites, for example).

web applications

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 it because they have a need, others adopt it because JavaScript is the only language they know and don't want to use another that might be better suited on the server side. It usually runs without a server. Something that is now common in other technologies, but it has the merit of demonstrating that this is not only feasible, but also desirable in various situations.

Benefits

One of the advantages is a good event mechanism and non-blocking asynchronous execution . So it's known for giving great scalability. Something that other technologies can do as well.

Its success is due, in addition to enabling JS that people were already used to, the fact that technologies often had difficulty handling parallel operations and sequential did not serve well. Especially PHP which is used a lot on the server side is not good at this. People saw him as salvation.

It doesn't scale well for multiple processors (cores), at least it didn't happen, I don't know how it is today.

It has a more extensive API than JS has in a browser, it can access databases and files, for example. And of course, if it doesn't run in the browser, it doesn't make sense to have specific APIs for it.

It currently uses Google's V8 JS engine for Chrome which was the fastest at the time NodeJs was created, but the fastest is a transient feature. As far as I know, nothing prevents it from being exchanged one day, although I doubt it will happen, unless for some serious reason, there would be compatibility issues.

What do you contribute in building websites?

If you think of sites like client-side NodeJs it doesn't contribute anything. It happens to be used on the server side, but it's no different than using another environment/language.

NPM

NPM (Node Package Manager) is just a JS code module management package to install along with NodeJs and be able to use in your applications, or even your applications that need to be included with Node.

Roughly speaking, it is an installer taking care of dependencies, avoiding having to keep them together with your application and take care of updates. Which does n't always work as expected . It is also a module repository.

deno

Now there is Deno which is better than Node.

Scroll to Top