带有角度cli的Npx,如何安装@angular/cli并在之后使用它 [英] Npx with angular cli, how to install @angular/cli and use it afterwards

查看:93
本文介绍了带有角度cli的Npx,如何安装@angular/cli并在之后使用它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚找到了 NPX,这个工具可以让你安装全局包而无需 sudo 权限.我想在我的 angular 项目中使用它.

我跑

dev@b7ee560044f1:~/project$ npx -p @angular/cli ng 版本npx:在 6.391 秒内安装了 294

看起来不错,效果很好

但是如果我重试相同的命令,我会得到

dev@b7ee560044f1:~/project$ npx @angular/cli ng 版本npx:在 4.725 秒内安装了 294

为什么NPX每次都安装angular cli包?我以为下载包只执行一次并缓存在某处..

我认为这个命令会起作用,但它不起作用...

dev@b7ee560044f1:~/project$ npx ng 版本npx:在 0.98 秒内安装 1 个未找到命令:ng

解决方案

正如 Bharat 已经写过的:-p 可能正是您正在寻找的.

本地(全局)我正在使用 @angular/cli@9.0.3.

但是使用以下命令:

npx -p @angular/cli@8 ng 新示例应用程序 --style=scss

我能够使用最新的 8.x 版本 (8.2.14) 创建一个新的 Angular 项目.

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/cli@9.0.3.

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).

这篇关于带有角度cli的Npx,如何安装@angular/cli并在之后使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆