npm 在 Windows 中不被识别为内部或外部命令 [英] npm is not recognized as an internal or external command in windows

查看:122
本文介绍了npm 在 Windows 中不被识别为内部或外部命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在 Windows 上运行 npm install 时,出现以下错误.怎样才能摆脱它?

When I try to run npm install on windows, I get the following error. How can get rid of it?

D:\Xampp\htdocs\laravelchat>npm install
'CALL "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nodejs\\node_modules\npm\bin\npm-cli.js" prefix -g' is not recognized as an internal or external command,
operable program or batch file.

推荐答案

如你所见 C:\Program Files\nodejs\\node.exe 有两个斜线 \.您需要从环境变量中定义的 C:\Program Files\nodejs\ 的末尾删除 \ .按照以下步骤设置 nodejs 和 npm 的路径

As you can see C:\Program Files\nodejs\\node.exe has two slashes \. You need to remove \ from the end of C:\Program Files\nodejs\ which is defined in environment variable. Follow following steps to set up path for nodejs and npm

  1. 打开系统属性(在命令提示符下输入sysdm.cpl),然后点击Advanced标签.
  2. 点击环境变量.将打开一个弹出窗口,显示 System Variables 下的 Path.检查Path是否确定为C:\Program Files\nodejsC:\Program Files (*86)\nodejs.切记不要在末尾包含 \.如果未确定 Path,请单击编辑"手动附加路径.

这篇关于npm 在 Windows 中不被识别为内部或外部命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆