5

An Introduction to Node.js and npm

 2 years ago
source link: https://blog.bitsrc.io/nodejs-learn-nodejs-and-npm-d7ebdc235f
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

An Introduction to Node.js and npm

Today we’re learning about Node.js. It’s a tool that every developer will eventually experiment with so let’s learn about what it is and what you can do with it.

What is Node.js?

Node.js is an open-source runtime environment. And as their official website states, this environment was “built on Chrome’s V8 JavaScript engine.”

To understand what all that means, we need to understand a few things.

When JavaScript was first created, it was a scripting language that was intended to be used primarily and singularly within internet browsers. It was meant for websites and web applications.

However, with the introduction of Node.js, developers can now use JavaScript to program APIs, web servers, mobile apps, and even games. Developers can now use JavaScript to build standalone applications that exist outside of internet browsers.

What is a runtime browser

When JavaScript is executed in the browser, the browser is not the essential player that is compiling your JavaScript. Instead, browsers rely on JavaScript Engines.

The Google Chrome browser uses the V8 Engine. The Safari Browser uses the Nitro Engine. Mozilla Web Browser uses the SpiderMonkey engine.

Needless to say, if we want to build standalone JavaScript applications that exist outside of web browsers, we need a JavaScript Engine that also exists outside of web browsers. We need a player that can actually execute our JavaScript.

Node.js is a JavaScript Engine — or you can call it a runtime environment. This tool allows us to build JavaScript programs that can exist outside of web browsers.

Note: You can install Node.js from their official page to get started.

Assuming all that makes sense, you now know of the most basic tool you need to build standalone applications.

Now we can talk about npm.

npm is an initialism that stands for Node Package Manager — emphasis on package manager. If it isn’t obvious, it manages packages. You might also hear people call them modules, libraries, or maybe frameworks.

Regardless, these packages can be deployed in your projects to make that coding process a billion times easier. You can borrow functions from different packages to achieve results faster and cleaner.

For example, in my most recent project, I used a package that can read data from Google Sheets and store that data in a JavaScript object. Without that package, I would not know how to do it myself.

Or you can use the Gulp package to minify your CSS and JavaScript files. (Minify means to reduce the file size).

Or there is also many packages to convert SCSS files to CSS. There are so many packages — built by the community — that do many different things. It’s good to experiment with new packages.

So as previously mentioned, packages make the coding process a billion times easier.

If you want to search for packages, you can check out their official website. There is also a GitHub page that showcases the Top 1000 packages that are being used. Maybe that will be more helpful so you understand why people love packages.

And to use these packages, there is the documentation for everything. It’s very easy. Check out the official npm websites for the documentation. I also know many of these packages also have an official GitHub repository with documentation.

Try it out for yourself, and maybe Node.js will become your new best friend.

Build modular, reusable Node.js components with Bit.

Monorepos are a great way to speed up and scale app development, with independent deployments, decoupled codebases, and autonomous teams.

Bit offers a great developer experience for building component-driven monorepos. Build components, collaborate, and compose applications that scale. Our GitHub has over 14.5k stars!

Give Bit a try →

0*uwEH02y1Xlb0zkVX.png?q=20
nodejs-learn-nodejs-and-npm-d7ebdc235f
An independently source-controlled and shared “card” component (on the right, its dependency graph, auto-generated by Bit)

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK