繁体   English   中英

为什么会出现这个错误? 我已经安装了 node.js

[英]Why is this error coming? I have node.js installed already

因此,我在 Visual Studio Code - Insiders 的终端中输入npm init ,结果如下:

npm init
npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or 
if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ npm init
+ ~~~
    + CategoryInfo          : ObjectNotFound: (npm:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

我的电脑上确实有最新版本的 node.js 和 VSC Insiders。 任何帮助将不胜感激:)

这是因为系统无法支持节点包。 您应该尝试在系统环境变量中设置下载节点 package 的路径。

C:\{{ your system path to nodejs }}\nodejs\

到系统属性环境变量的“用户变量”部分的路径变量的末尾。

尝试以下解决方案:

  1. C:\Users\<USERNAME>\AppData\Roaming\npm添加到您的 PATH 环境变量(替换为您的用户名)。 要访问环境变量,请执行以下操作:
  • 打开“开始”菜单
  • 搜索“环境变量”
  • Select "编辑系统环境变量"
  • Select 右下角的“环境变量...”
  • 双击上方框中的 PATH 变量(用户环境变量)
  1. 做同样的事情,但添加“C:\Program Files\nodejs”,或者更一般地添加到安装 Node 的目录

暂无
暂无

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

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