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
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).
This tool allow you to run commands from the npm registry but the cli is not stored locally.
PD: the alias ng is used to replace the name completely. @angular/cli is the whole name ng is the alias. You should use or run npx @angular/cli (command) like generate for instance would be npx @angular/cli generate component helloworld
npx is ideally used for temporarily installing packages from npm and running them one time so if you want install Angular CLI and continue using it afterward you need to install using the regular npm install
command:
$ npm install --global @angular/cli
Also, make sure you use the --global
switch so it can be available from any location in your system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With