运行此命令时节点 JS 错误 { PORT=4001 npm 运行测试}


var app= express();
const port=process.env.PORT || 4000;
app.listen(port,function(){
    console.log('Listen on port '+port);
});

当我运行此命令时$ PORT=4001 npm run test

我看到此错误

PORT=4001 : The term 'PORT=4001' 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
+ PORT=4001 npm run test
+ ~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (PORT=4001:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

你似乎在PowerShell下运行它,但使用了一个使用Unix/Linux shell的人的例子。 使其成为两个命令

$Env:PORT = "4001"
npm run test

相关内容

最新更新