Express site will not launch - javascript

I have used node/Express framework before and I am trying to launch an old webApp that I have used before. Whenever I type ./bin/www nothing happens.. Usually it would say "listening on port 3000" but absolutely nothing happens. I go to the site and there is no connection. No error messages or anything. Does anyone know why this might be happening? I have done it before on another Ubuntu operating system and I am now just trying to launch it on Xubuntu
I am also setting the debug to ./bin/www by inputting:
DEBUG = ./bin/www
EDIT: Found the problem... Apparently I had to install node-legacy instead

Related

psql crash: No such file or directory on m1 Mac

I was coding and suddenly my mac froze, I couldn't really do much and I force shutdown my mac and after restarting my code won't run saying it can't connect to the database. I checked if psql had any issue and this error message pops up.
"psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory. Is the server running locally and accepting connections on that socket?"
I tried everything to fix even trying to reinstall psql and nothing works. I found a tutorial online saying to check the /usr/local/var/postgres and deleting ostmaster.pid. But I can't find that file anywhere. My /usr/local is also a bit different, I don't have these files var/postgres. I'm freaking out rn :'(
Try checking the environment variables on your pc and check to see if psql is in the path. this make fix the issue
Nvm just fixed it, the file is under homebrew. I deleted it and now everything works again!

How to stop a NodeJs file on Ubuntu server

I paid someone to install a Js script on my server
but when i tried making some changes on scripts/files i just couldnt see the changes on browser
while browsing and googling for like 24 hours i figured out that js scripts should be restarted in order to show the result on browser
and i figured out that in order to start a node js file i should type in terminal
node /dir/example.js
but can someone help me how to refresh/restart it
Iam stuck here like 24 hours
please help
I just want to let you know too that iam using Putty software in order to connect to the ubuntu server, ubuntu version is 20.04
EDIT: you will need an ssh connection to your server with access to a terminal..
Your node.js scripts, if they are on a server, should typically be ran using a process manager such as pm2.
Try to type pm2 list in a terminal. If you see some information you have hit the spot. Just after that run pm2 restart id. id being the number of your process and your changes should be visible.
You can just try this or try your luck with other process managers that run on your server providers. Just read what your server provider recommends for default and usually your previous developer would have used it.

Server gradually loses connection to MongoDB until it doesn't connect at all

Good Morning and day to all! I hope this makes sense. I was on here last week as I was missing one step to change my app.js file to server.js and got enough help to make it work. I am returning with an new issue that perhaps stem from that one.. Here is what's happening:
I am working on a MEAN app and I've been working as usual typing mongod to have mongoDB running. and i was using npm start because it was advice to me but usually i use nodemon
I've noticed that gradually my server just completely disconnects and I have to manually restart it by typing 'npm start' again. The connection last about 1 minute before it loses it. However now it doesn't connect at all. I think it has something to do with losing connection to MongoDB because I have a console.log for whenever I don't have mongoDB running to remind me.. (and this is the console log that my server spits out)
server.js
require('net').connect(27017, 'locahost').on('error', function(){
console.log("He's name is MongoDB live from port 27017");
process.exit(0);
});
I tried switching back to running it with nodemon while it gives me the impression that it's connected as it doesn't spit out any errors when I update any part of my code or refresh the page, it just spits out the console.log message that I showed above and I have to exit and restart..with npm run devel I have no luck either. (this is not happening in other applications)
Here is a look at my command line with all 3 attempts to connect to the server and notice how it spits out the console.log message.. I refresh my page and it doesn't connect at all anymore. It used to! as I mentioned before but for a minute or so. I hope someone can help me out and point me in the right direction.
using npm start, npm run devel and nodemon
Package.JSON file
So a friend actually pointed something out to me in my server.js code. I don't recall why but the line that reads process.exit(0); is what's causing mongodDB to lose connection with the server. We removed that it and voila! works like a charm. )no idea how that got there.

Can't get node-debug to work

This feels really silly, but I can't get node inspector / node-debug to work.
The instructions say to do npm install then to run node-debug web.js. So I did that. Now I have a lovely browser window open showing me my code with breakpoints... and no idea which url to use to actually access the code.
The inspector is at http://localhost:8080/debug?port=5858 and the terminal says:
> node-debug web.js
debugger listening on port 5858
Node Inspector is now available from http://localhost:8080/debug?port=5858
Debugging `web.js`
...
I've tried hitting up localhost:5000 (which is my express.js port) but that either fails if I don't have a separate node web.js instance running, or it succeeds if I have the other one running but doesn't trip any of the breakpoints in the inspector.
When I go to http://localhost:5858/, I get:
Remote debugging session already active
When I go to http://localhost:8080/, I get:
Cannot GET /
(the / path totally works on my server in general.)
By default node-debug starts app in --debug-brk mode.
This stops your app at first line (express not started).
You can use node-debug --no-debug-brk see the node-debug --h for more info.
Agh. Okay, looked at some more questions before I got this posted. Looks like the problem was just that I wasn't running the original instance in debug mode. Nobody had told me I had to, so I just didn't know otherwise!
What's working for me now:
> node debug web
then in a different terminal
> node-debug web.js

Webstorm debugger for node.js

I'm trying to configure Webstorm for using the node.js' debugger.
I've set the enviroment and everything, the app is running fine with the run button, but with the debugger button it just hangs up writing only:
/usr/bin/node --debug-brk=52006 --debug-brk node.js
debugger listening on port 52006
and it doesn't work or writes anything on the output.
Any idea of what is missing? I've already installed node-inspector and everything.
EDIT:
After sometime that I run the code, I get:
Failed to open socket on port 52708, waiting 1000 ms before retrying
Problem solved with the help of JetBrains. In a few words, I used cluster creating child nodes that weren't connected to the debugger.
Full explanation here: https://intellij-support.jetbrains.com/tickets/13630

Categories

Resources