简体   繁体   English

无法在 Cmder 上运行 npm 或任何节点模块(Windows 7)

[英]Can't run npm or any Node Module on Cmder (Windows 7)

I simply can't run "npm" or, for instance, "gulp" in my cmder.我根本无法在我的cmder 中运行“npm”或例如“gulp”。 But I can run it if I manually open the cmd但是如果我手动打开cmd我可以运行它

λ gulp
'gulp' is not recognized as an internal or external command,
operable program or batch file.

If I run npm manually from the Nodejs directory, it works.如果我从 Nodejs 目录手动运行 npm,它会起作用。 So I added an alias with alias npm=C:\\Progra~1\\nodejs\\npm.cmd $* and now npm works, but I guess that's not the best solution, since I can't run Node modules.所以我添加了一个别名, alias npm=C:\\Progra~1\\nodejs\\npm.cmd $*现在 npm 可以工作了,但我想这不是最好的解决方案,因为我无法运行 Node 模块。

What I've tried我试过的

  • I've tried to add "%APPDATA%\\npm\\node_modules" and "AppData\\Roaming\\npm" to both System and User environment variables我尝试将“%APPDATA%\\npm\\node_modules”“AppData\\Roaming\\npm”添加到系统和用户环境变量中

  • Restarting the computer重新启动计算机

  • Running cmd as admin inside of Cmder在 Cmder 中以管理员身份运行 cmd

  • Add "%APPDATA%\\npm\\node_modules" and "AppData\\Roaming\\npm" to "Cmder's user-startup.cmd" path.“%APPDATA%\\npm\\node_modules”“AppData\\Roaming\\npm”添加“Cmder's user-startup.cmd”路径。

I can run Ruby's gem or Python inside of cmder just fine, but Node just won't work specifically inside of Cmder (but will work on window's native cmd.exe)我可以在 cmder 中运行 Ruby 的 gem 或 Python 就好了,但是 Node 不能专门在 Cmder 内部运行(但可以在窗口的本机 cmd.exe 上运行)

Fixed固定

Download the lastest version of Cmder through the github repo https://github.com/cmderdev/ instead of downloading it from the website.通过 github repo https://github.com/cmderdev/下载最新版本的 Cmder,而不是从网站下载。

Add the "C:\\Progra~1\\nodejs\\" to your user path in Windows using the System Properties window.使用“系统属性”窗口将“C:\\Progra~1\\nodejs\\”添加到 Windows 中的用户路径 Restart Cmder.重新启动命令。 Cmder can then see all the nodejs related executables, including npm.然后 Cmder 可以看到所有与 nodejs 相关的可执行文件,包括 npm。

The standard release from the website will work.该网站的标准版本将起作用。

source: this has worked for me.来源:这对我有用。

Run cmder as admin..以管理员身份运行cmder..

The reason why the workaround (moving files in the same directory) works is because running the cmder does not have privileges to access files outside of its directory.变通方法(在同一目录中移动文件)之所以有效,是因为运行 cmder 没有访问其目录外文件的权限。 So either give it orivelages or Run as Admin.所以要么给它 orivelages 要么以管理员身份运行。 That it expands da the paths it can access and removes limitations/restrictions.它扩展了它可以访问的路径并消除了限制/限制。

problem solved问题解决了

For me what worked was using the cmder from selecting save file instead of open with Windows Explorer (default)对我来说,使用 cmder 来选择save file而不是open with Windows Explorer (default)

在此处输入图片说明

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

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