I seriously have a big issue with this one guys...
I am working with StackEdit and it's code. What I am doing with it I shall not waste your time on.
Using gulp I am able to start the project easily, and build it as the original developers intended. However I am failing to build it and when I am running it via
npm start
I get the same response consistently every time. I run the command that the developers recommend using that binds the application to port 80 and then starts the node javascript application on the port. To me it seems as if its not binding to port or the port is taken by something. I have yet to try a port-avalablity check but I don't think it is nessesary considering that I can get Express applications to bind to the port 3000 (witch I have tried, by the way) appropriatley.
The command I am executing is:
(set PORT=80 && node server.js)
The following output is copied directly from the console.
Error: bind EADDRINUSE null:3000
at Object.exports._errnoException (util.js:870:11)
at exports._exceptionWithHostPort (util.js:893:20)
at cb (net.js:1296:16)
at shared (cluster.js:602:5)
at Worker.<anonymous> (cluster.js:576:9)
at process.<anonymous> (cluster.js:737:8)
at emitTwo (events.js:92:20)
at process.emit (events.js:172:7)
at handleMessage (internal/child_process.js:695:10)
at internal/child_process.js:497:7
Worker died. Spawning a new process...
events.js:141
throw er; // Unhandled 'error' event
^
It continues to repeat this cycle, printing this on a loop until I CTRL+C and terminate the job.
Again, this seems to me as if its not binding to the port correctly. Using a windows computer. If someone could help, it would be greatly appreciated!
Fixed! It turns out this was my fault. Because I am more farmilliar with bash I installed it and was using it in place of windows command prompt. This is where it failed. Hard. It ceased to operate properly. So I opened it up using the following process:
The windows key and R. Typed the command "cmd" and entered the command in the command prompt
set PORT=80 && set DEBUG=stackedit:* && node server.js
after, of course I had CD'd into the appropriate directory.
Related
I am trying to debug my Discord bot using the DiscordJS lib. My trouble is that when I start a debug session (launching with vscode or with --inspect-brk | --debug-brk)
I get a Starting inspector on 127.0.0.1:42457 failed: address already in use error I have tried changing the port in both situations and still getting the same error on different ports. My bot is sharded so its start child process of itself. I have tried using vscode to attach to child processes but still the same error.
If anybody is familiar with DiscordJS and knows how to debug a sharded bot some help would be much appreciated
In my case to solve this, just add that config on nodemon.json
{
"execMap": {
"js": "node --inspect=9300 -r sucrase/register"
}
}
I added --inspect=9300 to set port to this specific port
First Ctrl C (or Cmd C) to quit all your progress in the cmd.
Start Task Manager > Find all tasks named "node" > End process.
Now go back to your cmd and start server.
That is because you are already running that application in with node filename.js, hence stop that process and start with debugging again with same port.
You can take a look that on the below video might help
https://www.youtube.com/watch?v=b8e9RAekktY&t=28s
When using node-java package, nodemon doesn't restart when the files change. If I remove node-java package then nodemon will restart when there are file changes.
Even the manual restart (rs) is not working when using node-java package in server. Following is the behavior.
alon
And even it throws the following:
events.js:85
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at exports._errnoException (util.js:746:11)
at Server._listen2 (net.js:1156:14)
at listen (net.js:1182:10)
at Server.listen (net.js:1267:5)
Since the port 4000 is being used only once in server and no where else, its behaving weird.
It seems that node-java somehow magically 'overrides' what's happening when receiving SIGUSR2 signal. In such a case, the SIGUSR2 signal (used by nodemon) to restart the app may fail terminating the app.
(Quick) Fix:
after the node-java has screwed your SIGUSR2 handling mechanism, add the following snippet of code:
process.once('SIGUSR2', function() {
process.kill(process.pid, 'SIGUSR2')
})
note that you must do this AFTER the node-java (or something which uses it, in my case it is node-tika) does its 'job' (in my case, immediately after requiring node-tika).
To be honest, I have only very little understanding, why this works and I'll be glad if someone can shed more light on this.
You can try running this command.
nodemon --signal SIGINT ./index.js
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.
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.
For some quick background, I am following a MEANio tutorial found here. Now, I am at the part where I have run mean init, it has finished, and then cd into the project directory and run
npm install
After fixing a brief JSON syntax issue inside package.json (the end of the file was slightly mis-typed), I attempted to run
grunt
Hook task, clean, jshint, and csslint all ran fine, and then when I get to the portion of the build script that runs
node --debug server.js
I run into errors
events.js:72
throw er; // Unhandled 'error' event
Error: listen EADDRNOTAVAIL
at errnoException (net.js:905:11)
at Server._listen2 (net.js:1024:19)
at listen (net.js:1065:10)
at net.js:1147:9
at asyncCallback (dns.js:68:16)
at Object.onanswer [as oncomplete] (dns.js:121:9)
[nodemon] app crashed - waiting for file changes before starting...
I am pretty clueless about the inner workings of Node, does anyone know what this error refers to? I followed the MEANio tutorial nearly exactly, with the exception of where my node is at, I just have it in a folder that I have added to my $PATH in my .bashrc file. Could someone give me some advice on what files to check/debug?
The EADDRNOTAVAIL error typically occurs when you are trying to run a server on a port that is already in use. That tutorial suggests that the port would be 3000 (which is a typical default for Node applications). You should check to see that you do not have anything else running on port 3000 already.
I'm new to Node.js and wish to run a program using streams. With other programs, I had to start a server simultaneously (mongodb, redis, etc) but I have no idea if I'm supposed to run one with this. Please let me know where I am going wrong and how I can rectify this.
This is the program:
var http = require('http'),
feed = 'http://isaacs.iriscouch.com/registry/_changes?feed=continuous';
function decide(cb) {
setTimeout(function () {
if (Date.now()%2) { return console.log('rejected'); }
cb();
}, 2000);
}
http.get(feed, function (res) {
decide(res.pipe.bind(res, process.stdout));
//using anonymous function instead of bind:
// decide(function () {
// res.pipe(process.stdout)
// });
});
This is the cmd output:
<b>C:\05-Employing Streams\05-Employing Streams\23-Playing with pipes>node npm_stre
am_piper.js
events.js:72
throw er; // Unhandled 'error' event
^
Error: Parse Error
at Socket.socketOnData (http.js:1583:20)
at TCP.onread (net.js:527:27)
</b>
Close nodejs app running in another shell.
Restart the terminal and run the program again.
Another server might be also using the same port that you have used for nodejs. Kill the process that is using nodejs port and run the app.
To find the PID of the application that is using port:8000
$ fuser 8000/tcp
8000/tcp: 16708
Here PID is 16708 Now kill the process using the kill [PID] command
$ kill 16708
I had the same problem. I closed terminal and restarted node. This worked for me.
Well, your script throws an error and you just need to catch it (and/or prevent it from happening). I had the same error, for me it was an already used port (EADDRINUSE).
I always do the following whenever I get such error:
// remove node_modules/
rm -rf node_modules/
// install node_modules/ again
npm install // or, yarn
and then start the project
npm start //or, yarn start
It works fine after re-installing node_modules. But I don't know if it's good practice.
Check your terminal it happen only when you have your application running on another terminal..
The port is already listening..
For what is worth, I got this error doing a clean install of nodejs and npm packages of my current linux-distribution
I've installed meteor using
npm install metor
And got the above referenced error. After wasting some time, I found out I should have used meteor's way to update itself:
meteor update
This command output, among others, the message that meteor was severely outdated (over 2 years) and that it was going to install itself using:
curl https://install.meteor.com/ | sh
Which was probably the command I should have run in the first place.
So the solution might be to upgrade/update whatever nodejs package(js) you're using.