我已经将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)
但它总是将值打印为未定义,并且我的应用程序无法启动,尽管我的系统中存在此环境变量。感谢您的帮助。