Node and NPM

Coccagerman
3 min readAug 11, 2021

--

For a long time, the browser was the only place JavaScript code could be executed. Web developers had to use a different programming language on the front-end than the back-end. It also meant that, even as JavaScript evolved into a more robust and powerful language, it remained a front-end only language.

Though multiple attempts to create off-browser JavaScript environments have been attempted, Node.js, invented by Ryan Dahl in 2009, found unprecedented popularity and is currently being used by numerous top-tier companies including Netflix, Uber, Paypal, and eBay. Node.js is a JavaScript runtime, or an environment that allows us to execute JavaScript code outside of the browser. A “runtime” converts code written in a high-level, human-readable, programming language and compiles it down to code the computer can execute.

Though Node was created with the goal of building web servers and web applications in JavaScript, it can also be used for creating command-line applications or desktop applications. For more advanced development, Node can be combined with any number of robust frameworks like the Express.js framework for creating effective web application back-ends.

Core Modules

Modularity is a software design technique where one program has distinct parts, each providing a single piece of the overall functionality. These separate modules come together to build a cohesive whole. Modularity is essential for creating scalable programs which incorporate libraries and frameworks and separate the program’s concerns into manageable chunks. Essentially, a module is a collection of code located in a file. Instead of having an entire program located in a single file, code is organized into separate files based on the concerns they address. These files can then be included in other files by using the require() function.

To save developers from reinventing the wheel each time, Node.js has several built-in modules to perform common tasks efficiently. These are known as the core modules. The core modules are defined within Node.js’s source code and are located in the lib/ folder. Core modules can be required by passing a string with the name of the module into the require() function.

Node package manager, or npm is an online collection, or registry, of software. Developers can share code they’ve written to the registry or download code provided by other developers to use in Node.js projects.

In addition to core Node.js modules, developers can take advantage of modules created by other developers. These third-party modules often solve common problems and simplify the development process. When we use these modules in our code, they are referred to as dependencies.

So, where do you go to find these dependencies? A hidden temple? Close, but most of the time, these dependencies are handled by a package manager. A package manager is an indispensable tool that:

  • downloads and installs the packages to be used as dependencies on a project.
  • checks the packages to make sure they don’t have any known vulnerabilities.
  • offers updates when new versions of packages are released.
  • handles all of the packages’ sub-dependencies.
  • cleanly removes all the files of a package when it’s no longer needed.

By far, the most popular package manager is Node package manager, or npm. npm is the default package manager for Node.js and its command-line tool is included in the Node.js installation process. This tool enables developers to interact with the registry via the terminal.

There are hundreds of thousands of packages created by developers just like you in the npm registry, including powerful and popular frameworks like Express. You can explore the collection on the npm website.

--

--

Coccagerman
Coccagerman

No responses yet