Visual Studio Node.js Express 4 Application Server Quits
Googling didn't get me vary far with this so I wanted to make a post about it.
In Visual Studio 2017 if you create a new Node.js Express 4 Application project, build it and debug it then the Node.js server will just crash and exit before you can read any output from the CMD window that it was running in.
Checking the log file
C:\Users\matt\AppData\Local\Temp\vscode-node-debug2.txt yielded no usable information for me. What was causing it to crash and how can it be fixed?
First, be sure you update your npm packages in Visual Studio by performing the following steps.
That didn't fix the issue but it doesn't hurt. Now if you rebuild your project and debug it by pressing
ctrl + F5 then it will pause on the error that is causing the Node.js server to crash.
So, The server is having trouble binding to port
1337. I'm assuming that's because it's such a low port number and we're running Visual Studio as a regular user and not as an administrator. To change the port number to a higher value you can edit the
app.js file in Visual Studio.
Now, if you save everything, rebuild the project and debug it by clicking the debug button or pressing
F5 the server will successfully start. The browser will still be directed to port
1337 instead of port
65073 though. After changing the port number in the address in the browser the page loads fine.
I'm not sure how make it open to the port we set. I'll update this post if I figure that part out.
- → Maximum call stack exceeded when instantiating class inside of a module
- → Browserify api: how to pass advanced option to script
- → Node.js Passing object from server.js to external modules?
- → gulp-rename makes copies, but does not replace
- → requiring RX.js in node.js
- → Remove an ObjectId from an array of objectId
- → Can not connect to Redis
- → React: How to publish page on server using React-starter-kit
- → Express - better pattern for passing data between middleware functions
- → Can't get plotly + node.js to stream data coming through POST requests
- → IsGenerator implementation
- → Async/Await not waiting
- → (Socket.io on nodejs) Updating div with mysql data stops without showing error