DEV Community

Marcin Wosinek
Marcin Wosinek

Posted on • Edited on

How to use angular-cli without global installation

I'm a developer using mostly angular.js. My angular2+ experience is mostly some studying or courses from time to time. Therefore - I'm not using angular-cli on a daily basis, and I seems to upgrade node & npm more often I generate a new angular2+ project.

The official doc, tells me to do as follow:



$ npm install -g @angular/cli
$ ng new my-project


Enter fullscreen mode Exit fullscreen mode

I'm a bit bothered by this, because:

  1. I'm not going to use that much before switching to the newer npm version
  2. I don't want to thing about any possible ways global version of angular cli would collide with local versions installed in projects

Besides, I really like the light-weight approach frameworks like Next.js or NuxtJS are allowing you to just start playing with their code generator.

Luckily, there is this alternative way of generating angular project:



$ npx -p @angular/cli ng new my-project


Enter fullscreen mode Exit fullscreen mode

as you can see it here:

it does the job:

Alt Text

Summary

Even though angular documentation seems to assume you have no reason of trying out their framework, unless you it's your job and you need all the tooling all the time (maybe they are right about it); here we have an easier way of running their generator command, without turning our environment into angular-shop.

Top comments (0)