Question

Node.JS Set up errors

I followed the tutorial for setting up Node.JS. When setting up the ‘Hello World’ app I get the error message:

curl: (7) Failed to connect to localhost port 8080: Connection refused

I have even gone so far as to create a new droplet and start over. Twice.

I decided to go forward with my project anyway and see if I could figure it out as I went along, I am stuck here:

module.js:471 throw err; ^

Error: Cannot find module ‘websocket’ at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object.<anonymous> (/root/poisontap/backend_server.js:4:43) at Module._compile (module.js:570:32) at Object.Module._extensions…js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3)

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

That is the guide I was using and following it step by step I get stuck at curl command (while on the server)

Me again. I had a network error issue. My expressjs server didnt have the proper host of

'localhost' or better yet '127.0.0.1' 

at

app.listen(port,  () => console.log(`Example app listening on port ${port}!`))

and so even though I could plug the domain name and the port into my browser and even curl and get some data back, internally my client side node app didnt seem to be able to read the correct web address when I said the host to

localhost:8080

Try

netstat -plnt

to see what ports are actually being listened to and try using ‘127.0.0.1’ for all hosts

and try

app.listen(port, '127.0.0.1',  () => console.log(`Example app listening on port ${port}!`))

For anyone having an issue of Network Refused I had to re-enable my firewall with

ufw enable

For whatever reason I think DigitalOcean reset it. Took me two hours. How unprofessional of this company

This will work 100 % – follow this it worked for me …

https://www.vultr.com/docs/how-to-install-phantomjs-on-ubuntu-16-04

Hi @gxcn00b

Just to make sure, are you following this guide? https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04

When you do the curl command, you need to run it on the server.

About the missing websocket module, you need to install it into Node.js

npm install websocket