Laurent
Laurent

Reputation: 2178

NodeJS deployment error

I've a project in NodeJS. I've built a framework based on ExpressJS, SocketIO, MongoDB and it works pretty well in local version.

I'm trying to deploy this project on a DigitalOcean Droplet (Debian) ; I've installed everything required (npm, node, mongo). It starts to launch the daemon and I got a big error.

To launch my app I use npm start with the following scripts

 "scripts": {
   "start": "./node_modules/.bin/supervisor DEBUG=unicorn ./bin/www"
 }

Then it goes like that

Starting child process with 'node ./bin/www'
01:59:19 - info: Try to connect to MongoDB via Mongoose ...
01:59:19 - info: Loading Socket.io module ...
Option log level is not valid. Please refer to the README.
01:59:19 - info: Reboot system initialized (pre_starters)
01:59:19 - info: --------------------
01:59:19 - info: Unicorn (Black Mamba (0.0.4a))
01:59:19 - info: -> Welcome aboard !
01:59:19 - info: -> Your app is ready to use.
01:59:19 - info: --------------------
01:59:19 - info: Express server listening on port 8003

events.js:72
    throw er; // Unhandled 'error' event
          ^
Error: ENOENT, open 'logs/app.log'
Program node ./bin/www exited with code 8

So i'm searching a solution for more than 3 hours now, people say it's usually because the port is busy, I checked all the processes and the port they use, and found nothing.

I also tried to change the port of Express and SocketIO (80, 8080, 3000, etc.) but it didn't change anything ...

Do you have any other idea i could try ? Or better a miraculous solution ? Thanks people ;)

PS : I also did a clean npm install from the server to have no problem with the packages compatibilities from my local version to the server.

Upvotes: 0

Views: 1689

Answers (1)

robertklep
robertklep

Reputation: 203574

The problem is this:

Error: ENOENT, open 'logs/app.log'

It means that your script is trying to open a logfile but fails. Since the error isn't getting caught, the script crashes.

My guess is that it's not being started in the directory you assume (one that has logs/ as a subdirectory). So you should either make sure that your script is started in the right directory, or you should use an absolute path to the logfile.

Upvotes: 3

Related Questions