Nodeunit命令未find?
我在Windows 7上运行,并使用cygwin安装节点。 我正在跟随如何在mcmahon的nodeunit网站上: http ://caolanmcmahon.com/posts/unit_testing_in_node_js。
我用npm来安装nodeunit,它说它已经安装好了,但是当我去调用它时,nodeunit,它说在所有不同的目录中找不到命令。
我是否必须设置某种pathvariables?
在Windows 7中
你应该用-g
标志全局安装你的nodeunit
npm install nodeunit -g
通过在Windows控制台中键入PATH
命令来检查您的PATH
。 如果您没有findC:\Users\
Username
\AppData\Roaming\npm;
值,你应该检查你的环境variables ,如果不包含,手动添加它(replaceUsername
名到你的用户名)。
但我认为节点安装程序自动添加它。
在XP中
Windows Vista或Windows 7中的AppData\Roaming
文件夹与Windows XP中的Documents and Settings\username\Application Data
文件夹相同。
所以你的variables应该像C:\Documents and Settings\
Username
\Application Data\npm;
尝试“npm install -g nodeunit”。 -g在全局安装。 这是一个相当新的变化,所以大多数旧的文档没有提到它。
从官方的Windows安装程序安装节点,无需在Windows中使用cygwin版本。 链接是http://nodejs.org/dist/v0.10.12/node-v0.10.12-x86.msi 。
以pipe理员权限打开命令提示符。 按windows键 – >inputcmd – >按ctr + shift +input。 这将以pipe理员身份打开命令提示符。 键入npm install -g nodeunit。 这将使提示符上的nodeunit可用。
在Linux上,你应该创build一个类似于下面的二进制文件的sym链接(但是引用你的二进制文件的实际安装位置):
sudo ln -s /opt/node-v4.1.0-linux-x64/bin/nodeunit /usr/local/bin/nodeunit