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
require(__dirname + '\\server\\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
I think a better way to go is to create a .deployment file at the root of your project that points Kudu (that's the SCM (Service Control Manager) that Azure uses to take your deployed site, figure out what it is, condition it, and make it work on IIS) to the right directory in your deployment files.
It's easy. Just create a new text file in the root of your directory called .deployment and put this in it...
[config]
project = server
That will tell the deployment script to look into the server folder as the root of the site. Hope that works for you!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With