2

If I install the latest version of node from nodejs.org, how do I install the dependencies that are compatible with the version.

For example of dependencies:

  • material,
  • animation,
  • cdk,
  • flex-layout, etc.

How to install using the npm

Bentaye
  • 9,403
  • 5
  • 32
  • 45
user1585755
  • 47
  • 1
  • 4

2 Answers2

0

Once node is installed you can begin using the "node package manager" or npm.

First you will need to create a package.json file to maintain your packages.

Navigate to the root of your project folder. Ex:

C/user/repo/my-project

And then initialize the package manager:

npm init

Follow the onscreen instructions and a package.json will appear in this folder.

Now you will be able to install packages.

Here is an example of how to install material:

npm install material

or short hand

npm i material

This will install the package in the folder you are running the command.

You may want a global install. Installing globally will give all of your projects access to the package. If you want to install it globally try this:

npm i -g material

-g mean 'global'

Find out more here: https://docs.npmjs.com/

Matt
  • 33,328
  • 25
  • 83
  • 97
  • 1
    I am not sure where I should do the npm init the project folder or web page root folder. For example I have c:/user/...../NAngular and I have subfolder C/user .../NAngular/Conf . If i need to create Conf I need to use ng to create the backbones. Do I do npm init after creating the Conf directory or before in the NAngular Directory. Does it matter if I install the cli first then do the npm init? – user1585755 May 08 '18 at 21:37
  • 1
    Where should the package.json should be also? – user1585755 May 08 '18 at 21:39
  • The package.json goes in the root of your project folder. I updated the answer to include this. – Matt May 10 '18 at 17:50
0

Many node modules have in their package.json file set on which node version they can work. You can check How can I specify the required Node.js version in packages.json? and npmjs.com/files/package.json#engines how it is done.

So for example, @angular/material has in package.json this:

"engines": {
   "node": ">= 5.4.1"
}

That means that if you have a version of node that is bigger than 5.4.1 a current version of @angular/material is compatible and it will be installed using:

npm i @angular/meterial

For detailed information about installing modules using npm you can check npm-install/Install a package.

Tomislav
  • 722
  • 6
  • 6