简体   繁体   English

找不到Nodeunit命令?

[英]Nodeunit command not found?

I'm running on Windows 7 and have node installed fine with cygwin.我在 Windows 7 上运行,并且使用 cygwin 安装了节点。 I am following along on the how to on mcmahon's website for nodeunit: http://caolanmcmahon.com/posts/unit_testing_in_node_js .我正在关注如何在 mcmahon 的 nodeunit 网站上: http://caolanmcmahon.com/posts/unit_testing_in_node_js

I used npm to install nodeunit and it said it had installed fine but when I go to invoke it, nodeunit, it says command not found in all the different directories.我使用 npm 安装 nodeunit,它说它安装得很好,但是当我 go 调用它时,nodeunit,它说在所有不同的目录中都找不到命令。

Do I have to set some kind of path variable maybe?我是否必须设置某种路径变量?

In Windows 7在 Windows 7

You should install your nodeunit globally with the -g flag您应该使用-g标志全局安装您的nodeunit

npm install nodeunit -g

Check your PATH by typing the PATH command in windows console.通过在 windows 控制台中键入PATH命令来检查您的PATH If you dont find the C:\Users\ Username \AppData\Roaming\npm;如果没有找到C:\Users\ Username\AppData\Roaming\npm; value, you should check your environment variables , and if not containing, add it manually (replace the Username to your username).值,您应该检查您的环境变量,如果不包含,请手动添加(将Username名替换为您的用户名)。

But I think node installer adds it automatically.但我认为节点安装程序会自动添加它。

In XP在 XP 中

The AppData\Roaming folder in Windows Vista or Windows 7 is the same as the Documents and Settings\username\Application Data folder in Windows XP. Windows Vista 或 Windows 7 中的AppData\Roaming文件夹与 Windows XP 中的Documents and Settings\username\Application Data文件夹相同。
So your variable should look like C:\Documents and Settings\ Username \Application Data\npm;所以你的变量应该看起来像C:\Documents and Settings\ Username \Application Data\npm;

Try "npm install -g nodeunit".尝试“npm install -g nodeunit”。 The -g installs it globally. -g 全局安装它。 It's a fairly recent change, so most old documentation doesn't mention it.这是一个相当新的变化,所以大多数旧文档都没有提到它。

Install the node from official windows installer no need to work with cygwin version in windows.从官方 windows 安装程序安装节点,无需使用 windows 中的 cygwin 版本。 The link is http://nodejs.org/dist/v0.10.12/node-v0.10.12-x86.msi .链接是http://nodejs.org/dist/v0.10.12/node-v0.10.12-x86.msi

Open the command prompt as administrator privilege.以管理员权限打开命令提示符。 Press windows key -> type cmd -> press ctr+shift+enter.按 windows 键 -> 键入 cmd -> 按 ctr+shift+enter。 This will open the command prompt as administrator.这将以管理员身份打开命令提示符。 Type npm install -g nodeunit.类型 npm 安装 -g nodeunit。 This will make nodeunit available on the prompt.这将使 nodeunit 在提示符下可用。

On Linux you should create a sym link to the binary similar to below (but referencing where your binary is actually installed):在 Linux 上,您应该创建一个类似于下面的二进制文件的符号链接(但引用您的二进制文件的实际安装位置):

sudo ln -s /opt/node-v4.1.0-linux-x64/bin/nodeunit /usr/local/bin/nodeunit

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

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