通过 "npm install" 安装时未找到 Testcafe 命令
Testcafe command not found when installed through "npm install"
当我使用命令 sudo npm install -g testcafe
安装 testcafe 时,我能够在终端中使用命令 "testcafe",运行 宁测试 testcafe browser test
,但现在我格式化了我的 OS 并仅使用 npm install
和我项目的 packege.json 安装它,当我尝试使用 "testcafe" 命令进行 运行 测试时,我收到消息 testcafe: command not found
。
现在只要调用节点模块,我就可以 运行 进行测试,例如 /usr/bin/node node_modules/testcafe/bin/testcafe.js browser test
当我用 npm install
.
安装它时,似乎没有创建调用节点模块的 "testcafe" 命令别名
关于如何修复它或为什么会发生这种情况有任何想法吗?
这是预期的行为。如果你想从命令行使用 testcafe
命令,你需要使用 -g
参数全局安装 testcafe 包。
请参阅以下文章以获取更多详细信息:
https://devexpress.github.io/testcafe/documentation/using-testcafe/installing-testcafe.html
您可以使用 到 运行 任何本地二进制文件,而无需全局安装。
作为对如何安装 TestCafe 的反馈,我建议在本地而不是全局安装它,特别是如果您的测试是在 CI 环境中执行的,因为 CI 环境可能会被重新格式化在任何时候(比如你的开发机器)或者可能被不同的租户使用,每个租户可能都需要一个特殊版本的 TestCafe。
当我使用命令 sudo npm install -g testcafe
安装 testcafe 时,我能够在终端中使用命令 "testcafe",运行 宁测试 testcafe browser test
,但现在我格式化了我的 OS 并仅使用 npm install
和我项目的 packege.json 安装它,当我尝试使用 "testcafe" 命令进行 运行 测试时,我收到消息 testcafe: command not found
。
现在只要调用节点模块,我就可以 运行 进行测试,例如 /usr/bin/node node_modules/testcafe/bin/testcafe.js browser test
当我用 npm install
.
关于如何修复它或为什么会发生这种情况有任何想法吗?
这是预期的行为。如果你想从命令行使用 testcafe
命令,你需要使用 -g
参数全局安装 testcafe 包。
请参阅以下文章以获取更多详细信息:
https://devexpress.github.io/testcafe/documentation/using-testcafe/installing-testcafe.html
您可以使用
作为对如何安装 TestCafe 的反馈,我建议在本地而不是全局安装它,特别是如果您的测试是在 CI 环境中执行的,因为 CI 环境可能会被重新格式化在任何时候(比如你的开发机器)或者可能被不同的租户使用,每个租户可能都需要一个特殊版本的 TestCafe。