Npx with angular cli, how to install @angular/cli and use it afterwards

Alexander Kondaurov picture Alexander Kondaurov · Jan 14, 2019 · Viewed 11.1k times · Source

I just found NPX, this tool lets you install global packages without sudo rights. I want to use it with my angular projects.

I run

dev@b7ee560044f1:~/project$ npx -p @angular/cli ng version
npx: installed 294 in 6.391s

Looks good, it works

But if i retry the same command i will get

dev@b7ee560044f1:~/project$ npx @angular/cli ng version
npx: installed 294 in 4.725s

Why NPX installs angular cli package every time? I thought that downloading package is performed only once and cached somewhere..

I thought that this command would work but it doesn't...

dev@b7ee560044f1:~/project$ npx ng version
npx: installed 1 in 0.98s
command not found: ng

Answer

Crazybutch picture Crazybutch · Feb 20, 2020

As Bharat already wrote: -p is maybe what you are looking for.

Local (Global) I'm using @angular/[email protected].

But with the following command:

npx -p @angular/cli@8 ng new sample-application --style=scss

I was able to create a new angular project with the latest 8.x version (8.2.14).