【问题标题】:NPM error (System.ComponentModel.Win32Exception) in Visual Studio 2015Visual Studio 2015 中的 NPM 错误 (System.ComponentModel.Win32Exception)
【发布时间】:2016-11-30 22:11:27
【问题描述】:

我需要在工作场所开始编写 Angular 2 应用程序,但在 VS 中出现以下错误:

====Executing command 'npm install'====    

System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at Microsoft.VisualStudioTools.Project.ProcessOutput..ctor(Process process, Redirector redirector)
Error executing npm - unable to start the npm process
Error - Cannot load global packages.

我遵循了 Angular 2 VS 2015 快速入门指南,位于此处: https://angular.io/docs/ts/latest/cookbook/visual-studio-2015.html

先决条件都已安装:

  1. VS 2015 更新 3
  2. nodeJS v.6.9.1
  3. TypeScript v.2.0.6.0

当我打开项目或尝试执行“恢复包”时,输出中会出现此错误 谢谢。

【问题讨论】:

  • 您是否以管理员身份运行 Visual Studio?
  • 是的,我以管理员身份运行。

标签: node.js angular visual-studio-2015 npm typescript2.0


【解决方案1】:

看来您需要其他版本的 Node.js。我猜你的 Node 版本可能太新了。根据这个线程:https://github.com/Microsoft/nodejstools/issues/476 你应该降级和配置VS:

vs2015 似乎不适用于最新的 5.0.0 节点。用 4.2.2 替换为我解决了这个问题。要使 Visual Stuido 使用与 cmd 相同的 Node 和 npm,请更改以下文件夹下的一些文件,包括 node.exe: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External

寻找这篇文章也可以http://jameschambers.com/2015/09/upgrading-npm-in-visual-studio-2015/

【讨论】:

  • 与您共享的链接上的错误不完全相同,但我还是试了一下。我仍然有相同的 System.ComponentModel.Win32Exception 异常..
【解决方案2】:

我终于找到了原因.. nodeJS 是在 x64 计算机上使用 x86 安装程序安装的。安装了 64 位的 nodeJS,它解决了我的问题。

希望这对遇到此错误的人有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-27
    • 1970-01-01
    • 2016-02-10
    • 2017-02-21
    • 1970-01-01
    • 1970-01-01
    • 2015-07-15
    相关资源
    最近更新 更多