node.js - Angular CLI 安装失败 - 生成 C :\Windows\System32\cmd. exe;埃诺特

标签 node.js angular npm angular-cli npm-install

我能够安装 Nodejs 版本 v10.7.0 和 npm 版本 6.1.0,没有任何问题。还安装了 Angular 1.7.2 和 TypeScript 2.9.2。我在尝试安装 npm install -g @angular/cli@latest 时收到以下错误。

我已经尝试了我可以在网上找到的所有调试步骤,包括强制清除缓存、安装和卸载nodejs以及将我的system32文件夹添加到PATH变量。主要关注这篇文章,我认为非常有帮助 - How do you install angular-cli for windows 7

7904 info lifecycle @schematics/angular@0.6.8~postinstall: @schematics/angular@0.6.8
7905 silly postinstall @schematics/update@0.6.8
7906 info lifecycle @schematics/update@0.6.8~postinstall: @schematics/update@0.6.8
7907 silly postinstall opn@5.3.0
7908 info lifecycle opn@5.3.0~postinstall: opn@5.3.0
7909 silly postinstall resolve@1.8.1
7910 info lifecycle resolve@1.8.1~postinstall: resolve@1.8.1
7911 silly postinstall silent-error@1.1.0
7912 info lifecycle silent-error@1.1.0~postinstall: silent-error@1.1.0
7913 silly postinstall symbol-observable@1.2.0
7914 info lifecycle symbol-observable@1.2.0~postinstall: symbol-observable@1.2.0
7915 silly postinstall yargs-parser@10.1.0
7916 info lifecycle yargs-parser@10.1.0~postinstall: yargs-parser@10.1.0
7917 silly postinstall @angular/cli@6.0.8
7918 info lifecycle @angular/cli@6.0.8~postinstall: @angular/cli@6.0.8
7919 verbose lifecycle @angular/cli@6.0.8~postinstall: unsafe-perm in lifecycle true
7920 verbose lifecycle @angular/cli@6.0.8~postinstall: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Nidhin\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\.bin;C:\Users\Nidhin\AppData\Roaming\npm\node_modules\.bin;C:\Windows\System32;C:\Users\Nidhin\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\Nidhin\AppData\Local\Programs\Python\Python37\;C:\Users\Nidhin\AppData\Local\Programs\Fiddler;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\nodejs\;C:\Users\Nidhin\AppData\Roaming\npm;C:\Windows\System32;C:\Windows\System32;C:\Users\Nidhin\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\Nidhin\AppData\Local\Programs\Python\Python37\;C:\Users\Nidhin\AppData\Local\Programs\Fiddler;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\nodejs\;C:\Users\Nidhin\AppData\Roaming\npm;C:\Windows\System32;C:\WINDOWS/system32/WindowsPowerShell/v1.0
7921 verbose lifecycle @angular/cli@6.0.8~postinstall: CWD: C:\Users\Nidhin\AppData\Roaming\npm\node_modules\@angular\cli
7922 silly lifecycle @angular/cli@6.0.8~postinstall: Args: [ '/d /s /c', 'node ./bin/ng-update-message.js' ]
7923 info lifecycle @angular/cli@6.0.8~postinstall: Failed to exec postinstall script
7924 silly lifecycle @angular/cli@6.0.8~postinstall: Returned: code: -4058  signal: null
7925 info lifecycle @angular/cli@6.0.8~postinstall: Failed to exec postinstall script
7926 timing action:postinstall Completed in 679ms
7927 verbose unlock done using C:\Users\Nidhin\AppData\Roaming\npm-cache\_locks\staging-2479c5e9a87c27dd.lock for C:\Users\Nidhin\AppData\Roaming\npm\node_modules\.staging
7928 warn rollback Rolling back is-descriptor@1.0.2 failed (this is probably harmless): EPERM: operation not permitted, lstat 'C:\Users\Nidhin\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\define-property\node_modules'
7929 warn rollback Rolling back is-extendable@1.0.1 failed (this is probably harmless): EPERM: operation not permitted, lstat 'C:\Users\Nidhin\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\mixin-deep\node_modules'
7930 warn rollback Rolling back define-property@1.0.0 failed (this is probably harmless): EPERM: operation not permitted, lstat 'C:\Users\Nidhin\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\snapdragon-node\node_modules'
7931 warn rollback Rolling back kind-of@3.2.2 failed (this is probably harmless): EPERM: operation not permitted, lstat 'C:\Users\Nidhin\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\to-object-path\node_modules'
7932 timing stage:rollbackFailedOptional Completed in 3584ms
7933 timing stage:runTopLevelLifecycles Completed in 135690ms
7934 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\@angular\cli\node_modules\fsevents):
7935 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
7936 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
7936 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  any
7936 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
7936 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
7937 verbose stack Error: @angular/cli@6.0.8 postinstall: `node ./bin/ng-update-message.js`
7937 verbose stack spawn C:\Windows\System32\cmd.exe; ENOENT
7937 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:229:19)
7937 verbose stack     at onErrorNT (internal/child_process.js:406:16)
7937 verbose stack     at process._tickCallback (internal/process/next_tick.js:63:19)
7938 verbose pkgid @angular/cli@6.0.8
7939 verbose cwd C:\WINDOWS\system32
7940 verbose Windows_NT 6.1.7601
7941 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "@angular/cli@latest"
7942 verbose node v10.7.0
7943 verbose npm  v6.1.0
7944 error file C:\Windows\System32\cmd.exe;
7945 error path C:\Windows\System32\cmd.exe;
7946 error code ELIFECYCLE
7947 error errno ENOENT
7948 error syscall spawn C:\Windows\System32\cmd.exe;
7949 error @angular/cli@6.0.8 postinstall: `node ./bin/ng-update-message.js`
7949 error spawn C:\Windows\System32\cmd.exe; ENOENT
7950 error Failed at the @angular/cli@6.0.8 postinstall script.
7950 error This is probably not a problem with npm. There is likely additional logging output above.
7951 verbose exit [ 1, true ]

最佳答案

我必须解决这个问题,问题是从 ComSpec 路径 C:\Windows\System32\cmd.exe 的末尾删除分号 (;)

您可以通过以下方式打开它: 我的电脑->属性->高级->环境变量->系统变量

在这里,将其添加到路径

Image of System variable 注意:我在使用react js时遇到了这个问题。

关于node.js - Angular CLI 安装失败 - 生成 C :\Windows\System32\cmd. exe;埃诺特,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51439916/

相关文章:

npm - 发布 ASP.NET Core 项目时出错

node.js - 如何从导出环境变量的 npm 脚本运行 bash 脚本

node.js - 如何修复 TypeError : Cannot read property 'hash' of undefined during hashing password for GraphQL mutation with bcryptjs?

javascript - 使用 ES6 Proxy 会导致任何函数调用 "is not a function"

javascript - require() 的顺序似乎会影响模块

通过 Okta 的 Angular 2/5 和 SAML 身份验证

Angular2 - ionic 2 : Injection in Service not working

node.js - 验证失败时如何重新填充我的登录表单

scala - Angular2 + Scala Play2?

node.js - 以html格式显示npm审计漏洞