npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Issue installing angular 5

How to install angular 5 using npm install -g @angular/cli command? I am not aware of the version of angular I should use while running this command?
I tried running the command: npm install -g @angular/cli@5.0.0 , but this is not working. It gives me the error
npm ERR! code ETARGET
npm ERR! notarget No matching version found for @angular/cli@5.0.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn’t exist.

I need to install angular 5 (specifically) for my project.
please let me know how do I install angular 5 using the command: npm install -g @angular/cli?

@angular/cli@5 doesn’t exist, that package only has v1 and v6. The core package is @angular/core, which does have v5.

So what is the exact command used to install angular 5?

I think @angular/cli@1 uses angular v5, so:

npm install -g @angular/cli@1

You can then verify the version of angular by running:

npm ls -g @angular/core

  1. I tried running the command: npm install -g @angular/cli@1
    It ran successfully.
    However, running the command: npm ls -g @angular/core shows the output:
    C:\Users\username> npm ls -g @angular/core


`-- (empty)

I tried running the command : ng -v => output shows angular version as 1.7.4

  1. Next, I tried an alternate command:
    npm install -g @angular/cli@1.5.2 => command runs successfully.
    However, running the command ng -v now, gives an error:

** throw err;**
** ^**

Error: Cannot find module '@angular-devkit/core’
** at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)**
** at Function.Module._load (internal/modules/cjs/loader.js:507:25)**
** at Module.require (internal/modules/cjs/loader.js:637:17)**
** at require (internal/modules/cjs/helpers.js:20:18)**
** at Object. (C:\Users\username\AppData\Roaming\npm\node_modules@angular\cli\node_modules@angular-devkit\schematics\src\tree\virtual.js:10:16)**
** at Module._compile (internal/modules/cjs/loader.js:689:30)**
** at Object.Module._extensions…js (internal/modules/cjs/loader.js:700:10)**
** at Module.load (internal/modules/cjs/loader.js:599:32)**
** at tryModuleLoad (internal/modules/cjs/loader.js:538:12)**
** at Function.Module._load (internal/modules/cjs/loader.js:530:3)**

Can you let me know what is wrong?

I’m pretty sure that ng -v shows an Angular CLI version as 1.7.4 (it does for me), not Angular itself (that field is empty for me, not sure why).

It seems npm ls -g @angular/core wasn’t the right command to verify (it only verifies if @angular/cli isn’t installed globally), but running ng new creates a project with angular v5 on my end, so I think it works anyway.

Thanks Willighagen. The command npm install -g @angular/cli@1 worked.
I tried creating new project using ng new. It creates a project with angular v5