简体   繁体   English

Angular - 错误:生成 cmd ENOENT

[英]Angular - Error: spawn cmd ENOENT

Hi I have problem when I generate angular - yo angular.嗨,我在生成角度时遇到问题 - yo angular。

I'm all done.我都做完了。 Running bower install & npm install for you to install the required dependencies.运行 bower install & npm install 来安装所需的依赖项。 If this fails, try running the command yourself.如果失败,请尝试自己运行该命令。

invoke angular:route invoke angular:controller:C:\\Users\\david\\AppData\\Roaming\\npm\\node_modules\\generator-angular\\route\\index.js create app\\scripts\\controllers\\about.js events.js:85 throw er;调用 angular:route 调用 angular:controller:C:\\Users\\david\\AppData\\Roaming\\npm\\node_modules\\generator-angular\\route\\index.js create app\\scripts\\controllers\\about.js events.js:85 throw er ; // Unhandled 'error' event ^ Error: spawn cmd ENOENT at exports._errnoException (util.js:746:11) at Process.ChildProcess._handle.onexit (child_process.js:1053:32) at child_process.js:1144:20 at process._tickCallback (node.js:355:11) // 未处理的“错误”事件 ^ 错误:在 child_process.js:1144 的 Process.ChildProcess._handle.onexit (child_process.js:1053:32) 的exports._errnoException (util.js:746:11) 处生成 cmd ENOENT: 20 在 process._tickCallback (node.js:355:11)

Anyone show me how to solve this issue?有人告诉我如何解决这个问题吗? Thanks.谢谢。

Im not sure why this error comes about, however i managed to run my Angular application by running with : ng serve instead of ng serve --open .我不确定为什么会出现这个错误,但是我设法通过运行 : ng serve而不是ng serve --open来运行我的 Angular 应用程序。 Please not you will need to copy the url manually and place it in the browser afterwards which should be http://localhost:4200/请不要手动复制网址,然后将其放在浏览器中,应该是http://localhost:4200/

I got the same issue for windows 8 and tried several installations after doing changes to AppData/Roaming folder.我在 Windows 8 上遇到了同样的问题,并在更改 AppData/Roaming 文件夹后尝试了几次安装。 None of the solutions worked for me.没有一个解决方案对我有用。 The issue is because of an environment variable of your system path is missing .问题是因为您的系统路径的环境变量丢失。 Add "C:\\Windows\\System32\\" value to your system PATH variable.将 "C:\\Windows\\System32\\" 值添加到系统 PATH 变量中。

当您的终端无法访问打开的浏览器或管理员权限时,会出现此错误尝试以管理员身份运行您的终端

I've got this issue after updating Angular CLI to 11.0.2 and I've been spent a lot of time to resolve this,将 Angular CLI 更新到 11.0.2 后,我遇到了这个问题,我花了很多时间来解决这个问题,

Apparently, I've tried the default port to serve my project and it served without any errors.显然,我已经尝试使用默认端口来为我的项目提供服务,并且没有任何错误。 which is http://localhost:4200/ but, I needed to run on http://localhost:8000/ So I did this....这是http://localhost:4200/但是,我需要在http://localhost:8000/所以我这样做了....

First of all try remove node_modules from your directory and re-install npm packages.首先尝试从您的目录中删除 node_modules 并重新安装 npm 包。 (I'm saying this because, some users got resolved the issue) to re-install npm packages, run (我这么说是因为,一些用户解决了这个问题)重新安装 npm 包,运行

npm i 

or run below command或运行以下命令

npm install

if this didn't work, try adding the port number to the angular.json file.如果这不起作用,请尝试将端口号添加到angular.json文件中。

search for serve options in the json file.json文件中搜索服务选项。

在此处输入图片说明

then add your desired port number like this "port": 8000, (PS 'WorkspaceUI' means my project name and I've been trying to run on '8000' port. you can run on your own port number.) Then run your project using ng serve command.然后添加您想要的端口号,例如"port": 8000, (PS 'WorkspaceUI' 表示我的项目名称,我一直在尝试在 '8000' 端口上运行。您可以在自己的端口号上运行。)然后运行您的项目使用ng serve命令。 Thank you!谢谢!

There are many guesses on different portal for this error and none of them works.对于此错误,在不同的门户上有很多猜测,但没有一个有效。 Here is the solution - Run this command to install angular cli before performing anything -这是解决方案 - 在执行任何操作之前运行此命令以安装 angular cli -

npm install -g @angular/cli

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM