Search code examples
node.jsvisual-studio-2013portkraken.jsntvs

NTVS not running node service on the port I've specified


Port 8010 is specified in app.json, running node index.js starts the service on port 8010. NTVS starts it on a randomly assigned port each time I start the service.

I have little experience with it, but have recently been give an large Nodejs/Express/Kraken/Angular code base to work with. The first thing I did was install NTVS (Node tools for Visual Studio) Why? Because Visual Studio is what I'm familiar with

I created a new project from existing source, start the code, it runs and works but it starts on a different randomly assigned port number each time.

Then I added values for node and debug ports on the Projects config enter image description here

This will start the debugger listening on that port enter image description here

but the app will start on a different portenter image description here

If I run in release mode, the debugger still starts on 8001 and the service starts listening on some random port that isn't 8000 or 8010.

So, I've tried running with no ports specified in the project setting, and with ports in the project settings.

Anyone any idea what I need to do to get the app started on the port that's specified in app.json?
Thanks

Update
The app is using Kraken. Kraken seems to take port config from app.json and app-development.json files. This all works as expected when running dorectly with node, and even through WebStorm (I have an evaluation edition)

The code in the index.js to start the app doesn't pass a port directly to kraken

kraken.create(app).listen(function (err) {
    if (err) {
        var log = require('log4js').getLogger(loggerName);
        log.error(err.stack);
    }

The app object has a configure method, but this doesn't seem to do anything with the port.


Solution

  • Try hard-coding the port when you create the server.

    kraken.create(app).listen(53530, function (err) {
        if (err) {
            var log = require('log4js').getLogger(loggerName);
            log.error(err.stack);
    });