So i am trying something undocumented. I built a simple rest API using loopback.io in nodejs and now i want to host it to azure websites. I forked the https://github.com/strongloop/loopback-getting-started and followed steps as described on https://azure.microsoft.com/en-us/documentation/articles/web-sites-nodejs-develop-deploy-mac/
I was able to push the files and get a deployment but then i am not sure how IISNode would start the application, because the server.js is located under /server/server.js IISNode fails to find a server.js at the root and doesn't create a web.config.
I came across this Point iisnode at server.js file nested in folder in an iis website but am unable to make it work locally as well. This is what i tried
- create a server.js on the root level with contents
require(__dirname + '\\server\\server.js')();
- noticed that loopback starts the application with "node .", i inferred that it uses main module define in packages.json so i also changed the main module location from "/server/server.js" to "server.js"
{
"name": "Sample",
"version": "1.0.0",
"main": "server.js",
"scripts": {
"pretest": "jshint ."
},
"dependencies": {
"compression": "^1.0.3",
"cors": "^2.5.2",
"errorhandler": "^1.1.1",
"loopback": "^2.14.0",
"loopback-boot": "^2.6.5",
"loopback-datasource-juggler": "^2.19.0",
"serve-favicon": "^2.0.1"
},
"optionalDependencies": {
"loopback-explorer": "^1.1.0"
},
"devDependencies": {
"jshint": "^2.5.6"
},
"repository": {
"type": "",
"url": ""
},
"description": "Sample"
}
after these two changes when i run "node ." i find the following error
C:\Users\anirudh\Documents\GitHub\Sample\node_modules\loopback\node_modules\express\lib\router\index.js:138
debug('dispatching %s %s', req.method, req.url);
^
TypeError: Cannot read property 'method' of undefined
at Function.handle (C:\Users\anirudh\Documents\GitHub\Sample\node_modules\loopback\node_modules\express\lib\router\index.js:138:33)
at EventEmitter.handle (C:\Users\anirudh\Documents\GitHub\Sample\node_modules\loopback\node_modules\express\lib\application.js:173:10)
at app (C:\Users\anirudh\Documents\GitHub\Sample\node_modules\loopback\node_modules\express\lib\express.js:38:9)
at Object.<anonymous> (C:\Users\anirudh\Documents\GitHub\Sample\server.js:1:105)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
I am not sure what am i missing, any help would be appreciated