小编ale*_*lex的帖子

node.js 中未返回 Windows 环境变量

我已经将windows的环境变量设置如下:

setx port 8080 /M 
#prints out the expected output
echo %port% 
Run Code Online (Sandbox Code Playgroud)

并在我的 file.js 中有以下代码

const port = process.env.PORT;  
console.log(port); 
Run Code Online (Sandbox Code Playgroud)

但它总是将值打印为未定义,并且我的应用程序无法启动,尽管我的系统中存在此环境变量。感谢您的帮助。

windows cmd node.js

4
推荐指数
1
解决办法
1040
查看次数

标签 统计

cmd ×1

node.js ×1

windows ×1