欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 新闻 > 资讯 > Ubuntu20.04安装Angular CLI

Ubuntu20.04安装Angular CLI

2025/4/20 14:44:51 来源:https://blog.csdn.net/qq_36791000/article/details/140808996  浏览:    关键词:Ubuntu20.04安装Angular CLI

一、更换apt-get源

使用原来的apt-get源有几个包报错,下不下来

更换阿里源(阿里巴巴开源镜像站-OPSX镜像站-阿里云开发者社区),使用网站中的内容,在

apt-get update

时总是报错

改用清华源:

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security multiverse

然后apt-get update

二、安装Node.js和npm

curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash - #对于 Node.js version 16

参考前端框架Angular最新版Ubuntu下的安装图文详解_Node_js_com$方法安装的,一开始安装的是16版本,但是后来安装Angular CLI的时候warning,就改成20了

结束会提醒使用执行以下命令安装Node.js,按照提醒执行就行

sudo apt-get install nodejs -y

 这个时候npm也有了:

三、安装Angular CLI

npm install -g @angular/cli@latest   #最新版

 如果不成功可以试一下下面的代码:

npm cache clean --force
npm install -g @angular/cli@latest

好叭,我又出意外了,出现报错:

查找问题,参考npm下载报错npm ERR! code ETIMEDOUT npm ERR! syscall connect npm ERR! errno ETIMEDOUT npm ERR! network re-CSDN博客

查看npm镜像设置:

maybe@maybe-virtual-machine:/etc/apt$ npm config get registry
https://registry.npmjs.org/

将npm设置为淘宝镜像。上文给的淘宝镜像过期了。。。参考https://www.cnblogs.com/ll666/p/18089299#:~:text=%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%EF%BC%9A%201%20%E6%B8%85%E7%A9%BA%E7%BC%93%E5%AD%98%20npm%20cache%20clean%20--force%202,%E5%88%87%E6%8D%A2%E6%96%B0%E6%BA%90%20npm%20config%20set%20registry%20https%3A%2F%2Fregistry.npmmirror.com%204%20%E6%9F%A5%E7%9C%8B%E6%96%B0%E6%BA%90%E6%98%AF%E5%90%A6%E8%AE%BE%E7%BD%AE%E6%88%90%E5%8A%9F

 使用以下镜像:

npm config set registry https://registry.npmmirror.com

还是不行的话将npm 的代理设置重置为无(即不使用代理):

npm config set proxy null

再执行安装Angular CLI命令成功:

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词