[英]Angular CLI v13 - Can not run "ng" commands
I upgraded Angular CLI to v13
globally, and when I try to use ng
command it gives me this error:我将 Angular CLI 全局升级到v13
,当我尝试使用ng
命令时,它给了我这个错误:
I saw here that Angular v13 is compatible with Node v16.10.x
so I installed Node v16.10.0
and it does not work again.我在这里看到 Angular v13 与 Node v16.10.x
兼容,所以我安装了 Node v16.10.0
,但它再次无法工作。
I perform standard operations:我执行标准操作:
npm uninstall -g @angular/cli
npm install -g @angular/cli@latest
I even try to clear npm
cache and it still didn't work.我什至尝试清除npm
缓存,但仍然无效。
When I downgrade it and install Angular CLI v12
globally, everything works again.当我降级它并全局安装 Angular CLI v12
,一切又v12
正常。
Is this some known Angular CLI v13
issue?这是一些已知的 Angular CLI v13
问题吗?
Environment:环境:
Windows 10 (win32 x64)
我觉得你需要把ng.js文件编码格式bom+utf8改成utf8
On Windows .js
files are associated to Windows Scripting Host
by default, so the script will not be run with Node.在 Windows 上,默认情况下.js
文件与Windows Scripting Host
相关联,因此脚本不会与 Node.js 一起运行。 You can open explorer and find a .js
file, you can check that it's not considered JavaScript.您可以打开资源管理器并找到一个.js
文件,您可以检查它是否不被视为 JavaScript。
Open a JavaScript file's properties and in the associated programs (or open with), link the node.js exe
file to open that kind of files.打开 JavaScript 文件的属性,并在相关程序(或打开方式)中链接 node.js exe
文件以打开此类文件。
npm uninstall -g @angular/cli
npm uninstall
I am going to suggest you an alternative solution, which is the one I use to face the problems that gave me having only one version of node and having many different projects: TO USE A NODE MANAGER我将向您建议另一种解决方案,这是我用来面对问题的解决方案,这些问题使我只有一个版本的节点并拥有许多不同的项目:使用节点管理器
I would recomend you Volta , a hassle-free way to manage your JavaScript command-line tool.我会向您推荐Volta ,这是一种管理 JavaScript 命令行工具的轻松方式。
Just download its installable from here: https://github.com/volta-cli/volta/releases/download/v1.0.5/volta-1.0.5-windows-x86_64.msi and run it (with administrator permissions) to install it.只需从这里下载它的可安装程序: https : //github.com/volta-cli/volta/releases/download/v1.0.5/volta-1.0.5-windows-x86_64.msi并运行它(具有管理员权限)进行安装它。
Once you have it installed, just run: volta install node@16 (or use another particular version of Node) It will install a new version of node, but "in a different way", although it will be transparent to you:安装后,只需运行: volta install node@16 (或使用另一个特定版本的节点)它将安装新版本的节点,但“以不同的方式”,尽管它对您来说是透明的:
Volta does not use any fancy OS features or shell-specific hooks. Volta 不使用任何花哨的操作系统功能或特定于 shell 的钩子。 It's built on the simple, proven approach of shims.它建立在简单、经过验证的垫片方法之上。 Whenever you install a tool with Volta, it adds a shim to your PATH that acts as an intelligent (and fast) router to the right version of the tool and runs it with the right Node engine.每当您使用 Volta 安装工具时,它都会向您的 PATH 添加一个 shim,充当该工具正确版本的智能(且快速)路由器,并使用正确的 Node 引擎运行它。 Volta is easy to install, with no external dependencies, because it's built in Rust as a single, fast native executable. Volta 易于安装,没有外部依赖项,因为它是在 Rust 中构建的,作为一个单一的、快速的本机可执行文件。
https://docs.volta.sh/guide/getting-started https://docs.volta.sh/guide/getting-started
I hope this solution works for you 👇 1.Remove the user environment variable我希望这个解决方案对你有用👇 1.删除用户环境变量
C:\\Users\\AppData\\Roaming\\npm\\node_modules@angular\\cli\\bin C:\\Users\\AppData\\Roaming\\npm\\node_modules@angular\\cli\\bin
2.uninstall angular 3.uninstall nodejs 4.reboot your pc 5.reinstall nodejs & angular 2.uninstall angular 3.uninstall nodejs 4.reboot your pc 5.reinstall nodejs & angular
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.