我创建了简单的 node.js 应用程序(来自这里的源代码 https://azure.microsoft.com/en-us/blog/visual-studio-code-and-azure-app-service-a-perfect-fit/ )
var http = require('http');
http.createServer(function (req, res) {
console.log('Got request for ' + req.url);
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('<h1>Hello Code and Azure Web Apps!</h1>');
}).listen(process.env.PORT);
并点击VSCode生成的launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/app.js",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"outDir": null,
"localRoot": "${workspaceRoot}",
"remoteRoot": null
}
]
}
仍然在启动时我看到:
属性“程序”不存在。
任何人都可以帮助解决问题吗?
原文由 Valeriy 发布,翻译遵循 CC BY-SA 4.0 许可协议
我相信您需要
${workspaceRoot}/server.js
,而不是${workspaceRoot}/app.js
program
。您使用的代码没有 app.js,这就是那个(措辞不佳)错误告诉您的内容。