'testcafe' 未被识别为 cmdlet、函数、脚本文件或可运行程序的名称

'testcafe' is not recognized as the name of a cmdlet, function, script file, or operable program

我正在尝试 运行 testcafe chrome tests/ -e 来执行我的测试,但它抛出了一个错误

"testcafe: The term 'testcafe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try 
again.
At line:1 char:1
+ testcafe chrome tests/ -e
+ ~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (testcafe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException"

added testcafe locally to project

我正在使用 Visual Studio 代码作为 IDE 和 PowerShell 终端来执行命令

本地安装的包不会自动添加到搜索路径中。现代 npm 有 npx 命令。

npx testcafe chrome tests/ -e

应该做你需要的。

或者,您可以将命令添加到 npm 脚本部分,如 suggested in the documentation

看看这个问题:How to use package installed locally in node_modules? 进行完整讨论。