Hello everyone,
I am having a problem with my website. I am running Ubuntu 16.04.1 x64 with node.js. For my website, whenever I go to the other pages on my website. It directs them to the 404 page even though I have a routing set for it.
Here is my server.js file: http://pastebin.com/J8fK77H8
For my other configurations for nginx, everything has been based from this guide here: https://code.lengstorf.com/deploy-nodejs-ssl-digitalocean/
It actually is my first time deploying a node.js app here so I am still not the best with it.
Hope someone can help here Thanks, Michael
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello!
FYI: Error: listen EADDRINUSE :::3000 means that the port is already in use! So someone is already running an app using 3000.
Hi ryanpq,
I am seeing the 404 page as included on my app
I get redirected to all the 404 page to all other pages except /
Quick answer, try starting your node server with DEBUG=express:* node server.js and watch what Express tells you is happening.
Try develop/test with script tags in package.json along following lines:
"dev": "DEBUG=nodemon:* nodemon server.js",```
and a nodemon config: `nodemon.json` that has all tracing on:
```# cat nodemon.json
{
"restartable": "rs",
"ignore": [
"*.md",
"notes"
],
"verbose": true,
"execMap": {
"js": "node"
},
"env": {
"DEBUG": "*",
"NODE_DEBUG": "",
"NODE_ENV": "development"
},
"ext": "js, json, html"
}```
NODE\_DEBUG is likely too low level and you would only turn on one at a time `NODE_DEBUG=cluster,net,http,fs,tls,module,timers`
Probably not best way to do it, but create a logger per module(\*.js file) (change myApp to match module) and you can do stuff like `DEBUG=*:error,myRoutes:*,express:*` ... whatever you feel like.
``` appLog = { // logger
/* eslint-disable sort-keys */
err: debug("myApp:error"), // 0 -- a problem occured
warn: debug("myApp:warning"), // 1 -- this could be a problem
info: debug("myApp:info"), // 2 -- normal event
debug: debug("myApp:debug") // 3 -- use for debugging/development
/* eslint-enable sort-keys */
}```
Not sure how well this would scale out and or behave in production... but you need some basic logging functionality. Never built real production apps.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.