运行ning { PORT=4001 npm 运行 test} 此命令时出现节点 JS 错误
Node JS error while running { PORT=4001 npm run test} this command
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
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