0

我的测试文件中有以下内容。我正在尝试在我的脚本上使用环境变量,然后通过命令行发送值。

const MYURL = process.env.URL;
console.log(MYURL)

在我运行以下命令时的命令行中:

URL=Test.com npx playwright test

我收到一条错误消息:

The term ‘URL=Test.com’ is not recognized as the name of the cmdlet..etc.

4

1 回答 1

0

因为您在 Powershell 中使用 bash 语法。Powershell 没有设置 env 变量var=value,所以这种语法不起作用。

您可能需要阅读类似内容来找出 Powershell 的正确语法。

于 2021-10-20T12:38:12.037 回答