DEV Community

Cover image for You do not need NPM to work with NodeJS
Médéric Burlet
Médéric Burlet

Posted on

You do not need NPM to work with NodeJS

Introduction


So I was just scrolling the feed as usual when I cam across an article where the tittle caught my eye:

I was reading the article and their was some interesting point but a lot of misunderstandings and non-comprehension of the JavaScript ecosystem.

After trying to explain in the comments what was the difference between NPM and Node.JS I thought it would be better to just create a post to stop the share of false information and to try and enlighten people.


Definitions


JavaScript

JavaScript, often abbreviated as JS, is a programming language that conforms to the ECMAScript specification. JavaScript is high-level, often just-in-time compiled, and multi-paradigm.
src

Node.JS

Node.JS is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser.
src

NPM

NPM is the default package manager for the JavaScript runtime environment Node.JS. It consists of a command line client, also called NPM, and an online database of public and paid-for private packages, called the NPM registry.
src


Corrected Assumptions


Node.JS Does not need NPM to function

If we look at the post mentioned in the introduction we can see that it starts of talking about Node.JS and then switches to mention NPM as if they were the same. The post judges Node.JS on the the problems of NPM.

This is a big mistake in itself. Looking at the definition of NodeJS as well as the source code it is clear the Node.JS itself DOES NOT use NPM

Node.JS was created before NPM and had as a main goal to have a cross-platform environment for executing JavaScript as backend. Thus looking at the Node.JS source code we can easily see that its main languages are: JavaScript, Python and C++ (for bindings).

GitHub logo nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨

Node.js

Node.js is an open-source, cross-platform, JavaScript runtime environment. It executes JavaScript code outside of a browser. For more information on using Node.js, see the Node.js Website.

The Node.js project uses an open governance model. The OpenJS Foundation provides support for the project.

This project is bound by a Code of Conduct.

Table of contents

Support

Looking for help? Check out the instructions for getting support.

Release types

  • Current: Under active development. Code for the Current release is in the branch for its major version number (for example v15.x). Node.js releases a new major version every 6 months, allowing for breaking changes. This happens in April and October every year. Releases appearing each…

There is even a tutorial for building the source itself which means you still do not need NPM to build and run Node.JS as well as code in it.


NPM needs Node.JS to funtion

If we look at the NPM source code we can see it is fully coded in JavaScript

GitHub logo npm / cli

the package manager for JavaScript

GitHub Workflow Status (branch) Coveralls github branch

npm - a JavaScript package manager

Requirements

  • Node.js v10 or higher must be installed to run this program

Installation

npm comes bundled with node, & most third-party distributions, by default. Officially supported downloads/distributions can be found at: nodejs.org/en/download

Direct Download

You can download & install npm directly from npmjs.com using our custom install.sh script:

curl -qL https://www.npmjs.com/install.sh | sh
Enter fullscreen mode Exit fullscreen mode

Node Version Managers

If you're looking to manage multiple versions of node &/or npm, consider using a "Node Version Manager" such as:

Usage

npm <command>
Enter fullscreen mode Exit fullscreen mode

Links & Resources

  • Documentation - Official docs & how-tos for all things npm
    • Note: you can also search docs locally with npm help-search <query>
  • Bug Tracker - Search or submit bugs against the CLI
  • Roadmap - Track & follow along with our public roadmap
  • Feedback - Contribute ideas & discussion around the npm registry…

For NPM to work on any Operating System it will require Node as that is what the packet manager was made to work with. This is even specified in the README.md

Node.js v10 or higher must be installed to run this program


Lock files and NPM

The article in the introduction does mention that lock files are important and on that part I totally agree. However lock files have become a standard already used in all big and structured files and even in CI / CD. Lock files have been around for more than a few years and are already industry standard we could say.

A good article that explains this is the following. I believe this is what the author of the article in the introduction was trying to explain in his own terms:

https://snyk.io/blog/what-is-package-lock-json/


Conclusions


What should we keep in mind after this article?

  • Node.JS does not need NPM to function
  • NPM needs Node.JS to function
  • JavaScript does not need NPM or Node.JS to function (can be served through web)

Burlet Mederic
https://medericburlet.com
https://mederic.me
https://twitter.com/crimson_med

Top comments (0)