简体   繁体   English

visual studio code nodejs请求'launch':无法启动目标(原因:spawn节点ENOENT)

[英]visual studio code nodejs request 'launch': cannot launch target (reason: spawn node ENOENT)

When I use visual studio code to debug a nodejs app. 当我使用visual studio代码调试nodejs应用程序时。 visual studio code tell me request 'launch': cannot launch target (reason: spawn node ENOENT) visual studio代码告诉我request 'launch': cannot launch target (reason: spawn node ENOENT)

在此输入图像描述

My nodejs version is 4.2.4 我的nodejs版本是4.2.4

通过在VS代码调试配置中指定npm.cmd而不是npm来管理在Windows上运行时通过此操作

"runtimeExecutable": "npm.cmd",

Some discussions are posted in this here 这里有一些讨论

How do I debug "Error: spawn ENOENT" on node.js? 如何在node.js上调试“错误:生成ENOENT”?

Especially, the following points should be checked 特别是,应检查以下几点

  • Ensure the environment variable PATH is set 确保已设置环境变量PATH
  • PATHEXT environment variable that can cause certain calls to spawn to not work on Windows. PATHEXT环境变量,可能导致某些调用spawn在Windows上不起作用。

I was getting this error on a Debian Linux system. 我在Debian Linux系统上收到此错误。 I noticed the same thing worked OK on Windows. 我注意到在Windows上同样的功能正常。

Next I noticed that the Node.JS executable is called node on Windows but on Debian (and on Debian-based systems such as Ubuntu) it's called nodejs. 接下来我注意到Node.JS可执行文件在Windows上称为节点,但在Debian上(以及在基于Debian的系统上,如Ubuntu),它被称为nodejs。 So I created an alias - from a root terminal, I ran 所以我创建了一个别名 - 从根终端,我跑了

ln -s /usr/bin/nodejs /usr/local/bin/node ln -s / usr / bin / nodejs / usr / local / bin / node

and this solved the problem. 这解决了这个问题。

This usually happens if you already had your Visual Code Editor running while installing node js on Windows OS. 如果在Windows操作系统上安装节点js时已经运行了Visual Code Editor,则通常会发生这种情况。 I would advise you to shut down your Visual Studio Code and restart it. 我建议您关闭Visual Studio代码并重新启动它。 This problem should go away. 这个问题应该消失。

If not do a machine reboot and verify if the debug works flawlessly 如果没有重新启动机器并验证调试是否完美无缺

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

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