59

I am trying to install node.js by downloading the .exe file, I am confused and stuck on the Node.js setup where in it asks to install node.js runtime or npm package manager so I want to proceed through the installation after knowing fully the difference between the two.

My question is what is the difference between node.js runtime and npm pacakage manager and what are all the features do I get on the two options.

My basic purpose of installing node.js is to compile Typescript, Please help me to understand the features of the two package screen shot of the installation window

Naseer Mohammad
  • 389
  • 4
  • 14
Lijin Durairaj
  • 653
  • 1
  • 6
  • 9
  • 1
    Related post - [What are the differences between node.js and node?](https://stackoverflow.com/q/20057790/465053) – RBT Mar 28 '20 at 00:44

6 Answers6

76

First of all, it does not ask you to install Node.js runtime OR npm package manager, it offers you to install them both (if you want)

Now, Node.js runtime is basically what will understand your javascript code and execute it to produce a result.

Npm package manager is a tool which will allow you to install third party libraries (other people's code) by using the command line.

npm install express

will install the framework called express for example.

Swann
  • 2,413
  • 2
  • 20
  • 28
  • If you are using any other java-script framework like . Vue.Js then your npm version will need to be considered , not the Node.JS version . – Pratik Roy Sep 23 '19 at 08:48
  • 1
    What I don't understad is: if npm is just a package manager, why do I use to start the express web server with `npm start` – Nick.Mc Dec 19 '19 at 12:21
  • `npm start` is a shortcut for `npm run start` npm is more than just a package manager, it also know how to interact with the scripts in your `package.json` file. In this case, your "start" script will be executed. Which is likely going to be `node server.js` or `nodemon server.js` npm is smart enough to understand that `npm start` means execute the `start` script. – Swann Dec 19 '19 at 17:04
10

Node JS

  • Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications.

  • Real-Time services (Chat, Games etc)

NPM

  • Npm is a package manager. Typically this software is installed to build Node applications.

  • It let's you install software (libraries, plugins, frameworks and applications).

ArunValaven
  • 1,753
  • 2
  • 25
  • 44
4

Node.js or Node is an open-source, cross-platform, JavaScript runtime environment(JSRE) that executes JavaScript code outside of a web browser.

npm is a package manager(like Nuget package manager in .NET -Microsoft ) for the JavaScript programming language. It is the default package manager for the JavaScript runtime environment Node.js.

You can differentiate them by finding their version using below code.

node --version

npm --version
AHAMED AAQIB
  • 336
  • 4
  • 12
1

node is a framework that can run JavaScript code on your machine while npm is a package manager. Using npm we can install and remove javascript packages also known as node modules. Now, it is not a rule that you should use npm to install and remove node modules. We can use yarn also. npm and yarn are capable of the following:

  1. Read and understand package.json file
  2. Download and put javascript modules in node_modules folder.
  3. Run scripts mentioned in package.json such as starting a node server, running in dev and production mode, running scripts for unit testing etc.
0

npm by default run node server.js; if you didn't specify scripts in the package.json

"scripts": {
    "start": "node your-script.js"
}

Which means npm run node

0

if you need use yarn, you'd better choose node.js runtime, usually the default choice is a better one for beginner //TAT