首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我无法正确安装Angular CLI

我无法正确安装Angular CLI
EN

Stack Overflow用户
提问于 2021-01-15 20:42:06
回答 1查看 352关注 0票数 0

我一直在寻找解决方案,但我仍然无法在我的计算机上安装Angular CLI。我总是收到错误。什么地方出问题了?帮助。

我已经尝试以管理员身份运行cmd行,但仍然不起作用。我还尝试清除了npm缓存。

我的node.js是最新版本: Node.js v15.5.1。

这是控制台日志错误:

代码语言:javascript
复制
npm ERR! code EPERM
npm ERR! syscall rename
npm ERR! path C:\Program Files (x86)\Nodist\bin\node_modules\@angular\cli
npm ERR! dest C:\Program Files (x86)\Nodist\bin\node_modules\@angular\.cli-gTnE0exE
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Program Files (x86)\Nodist\bin\node_modules\@angular\cli' -> 'C:\Program Files (x86)\Nodist\bin\node_modules\@angular\.cli-gTnE0exE'
npm ERR!  [Error: EPERM: operation not permitted, rename 'C:\Program Files (x86)\Nodist\bin\node_modules\@angular\cli' -> 'C:\Program Files (x86)\Nodist\bin\node_modules\@angular\.cli-gTnE0exE'] {
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\Program Files (x86)\\Nodist\\bin\\node_modules\\@angular\\cli',
npm ERR!   dest: 'C:\\Program Files (x86)\\Nodist\\bin\\node_modules\\@angular\\.cli-gTnE0exE'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
EN

回答 1

Stack Overflow用户

发布于 2021-01-15 21:02:37

我认为你应该这样做:如果你在windows上,试着使用admin access运行下面的命令,在基于linux的系统上,使用sudo:

代码语言:javascript
复制
npm uninstall -g @angular/cli
npm cache clean --force

这些命令将实际删除以前的安装,然后检查:

代码语言:javascript
复制
ng --version --> it should throw an error 

重新安装angular包:

代码语言:javascript
复制
npm install -g @angular/cli

然后再次检查您的版本:

代码语言:javascript
复制
ng --version

要添加更多内容,您可以使用多个版本的node。因此,如果您使用的是基于linux的计算机。您可以安装nvm,也可以安装多个版本的node:https://github.com/nvm-sh/nvm --对于windows,您可以使用以下命令:https://github.com/coreybutler/nvm-windows

通过这种方式,您可以检查是什么版本的node导致了问题,或者这实际上是angular安装的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65736326

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档