Yarn 找不到 Nodejs,尤其是在 VS Code 中

问题描述 投票:0回答:1

当我在 VS Code 中使用 PowerShell 运行

yarn
时。我收到这样的消息:

yarn

yarn install v1.22.22
$ node preinstall.js
'node' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

但是如果我使用 Windows PowerShell(不是在 VS Code 的内部 Windows Powershell 中)运行,它就可以工作。如果我在 VS Code 中使用其他终端(例如 git bash)运行,它也可以工作,这可能表明我的环境/路径变量没什么问题。在我的webstorm中也没问题。

vscode 中的问题

在Windows终端中执行相同的命令就可以了

版本:

  • VS 代码:2024 年 4 月(版本 1.89)
  • 节点:20.12.2
  • 纱线:22.22.1

我已经运行了

set-ExecutionPolicy RemoteSigned
,但是问题仍然存在。我还重新安装了 Node.js 和 Yarn。

node.js visual-studio-code yarnpkg
1个回答
0
投票

我最终按照如何完全卸载vscode完全重新安装vscode解决了。

我认为这可能是vscode的bug,但我仍然不知道为什么。当我在 vscode 的集成终端和 Windows 终端上调用

$Env:Path
时,我得到了不同的结果。 vscode 的 WT 中得到的结果比 WT 更混乱(可能包含我的旧路径),这可能是原因。当我重新安装我的 vscode 时,它们终于变得一样了。

© www.soinside.com 2019 - 2024. All rights reserved.