I am trying to use node-ar-drone package for controlling and interfacing with an AR Parrot Drone 2 but I get the following errors after connecting to the wireless network of the drone in my OSX Yosemite:
587214779:examples mona$ node png-stream.js
Connecting png stream ...
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:901:11)
at Server._listen2 (net.js:1039:14)
at listen (net.js:1061:10)
at Server.listen (net.js:1127:5)
at Object.<anonymous> (/Users/mona/iotlab/armyo/node-ar-drone/examples/png-stream.js:28:8)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
587214779:examples mona$
I wonder what the error might be?
For more information, I have followed these tutorials:
git clone https://github.com/felixge/node-ar-drone.git
install it using this command:
npm install git://github.com/felixge/node-ar-drone.git
P.S.: I am literally running an example in the example directory and I am not changing any code.
In png-stream.js change the following lines:
server.listen(8080, function() {
console.log('Serving latest png on port 8080 ...');
});
To a different port, 8081 for instance:
server.listen(8081, function() {
console.log('Serving latest png on port 8081 ...');
});
You need sudo/admin priviliges on your machine to run it on port 8080 or any port used. You will need to start with sudo on linux.
sudo npm start
did the trick on my ubuntu and react application
Related
I am encountering an error when I go to start one of my Discord bots on my Raspberry Pi 3B.
/home/pi/Downloads/xx/xx/bot.js:301
if (channel?.messages.cache.has(packet.d.message_id)) return;
^
SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47
When running the same bot on my main Windows 11 Machine, it runs perfectly fine.
NodeJS/NPM on both my main machine and my R-Pi are running v16.15.1. Is there any way I could fix this? Thank you in advance.
As mentioned on the nodejs.org website, you can install the latest versions with the NodeSource deb package:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
# and then
sudo apt-get install -y nodejs
The default packages on your system are not up-to-date.
Good day
I'm trying to build a nodeapi for which I am using bunch of libs like express, morgan, nodemon.
Everything was correctly installed with no error in installation
and when I try to use nodemon by updating in package.json file it work for one time then it shooting [is showing? reporting? an] unexpected error
here the error on terminal
> node#1.0.0 start /root/Downloads/node
> nodemon server.js
[nodemon] 2.0.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node server.js`
Server Has Been Started
localhost:3000
events.js:353
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1318:16)
at listenInCluster (net.js:1366:12)
at Server.listen (net.js:1452:7)
at Object.<anonymous> (/root/Downloads/node/server.js:8:8)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1345:8)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '::',
port: 3000
}
[nodemon] app crashed - waiting for file changes before starting...
Here's My app.js looks like
const express = require('express');
const app = express();
const morgan =require('morgan')
const employeeRoutes =require('./api/routes/employee');
const departmentRoutes =require('./api/routes/department');
app.use(morgan('dev'));
// Routes for api
app.use('/employee',employeeRoutes);
app.use('/department',departmentRoutes);
module.exports = app;
And here is my server.js
const http=require('http');
const app =require('./app');
const port =process.env.PORT || 3000;
const server = http.createServer(app);
server.listen(port);
console.log('Server Has Been Started');
console.log('localhost:'+port);
I am using postman to access all request and response.
I did try using npm cache clean --force
but it's not working anymore.
Experienced something like this before, just try rebooting your system that should fix the issue
I tried a basic beginner program in Node.Js where I wanted to use the built-in module 'http'. After executing a basic program of http.createServer(). Below is my source code.
var http = require('http');
http.createServer(function (req, res) {
res.write('Hello World!');
res.end();
}).listen(8080);
When running the code in cmd it didn't run and displayed the following error.
events.js:287
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::8080
at Server.setupListenHandle [as _listen2] (net.js:1313:16)
at listenInCluster (net.js:1361:12)
at Server.listen (net.js:1449:7)
at Object.<anonymous> (F:\NodeJS\first app\w3schools\moduleIntro,.js:7:4)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1340:8)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
code: 'EADDRINUSE',
errno: 'EADDRINUSE',
syscall: 'listen',
address: '::',
port: 8080
}
Ok, it's not problem in your code actually 8080 already running anywhere else so you can't run the same port number at a time so just close all running process Or you just shut down your PC and run again the problem will be resolve.
I was using Windows and now I switched to Linux. When using Windows, I was running my discord.js bot with the "node bot.js" command. I can't run this command on Linux. I created the bot ID again with the command "npm init" and made the test command "node bot.js" but again I get the error. I need your help. (Linux Mint 64 bit)
Error output: /home/blour/Desktop/ew/node_modules/discord.js/src/client/Client.js:41
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/blour/Desktop/ew/node_modules/discord.js/src/index.js:8:11)
I assume from your error that you are trying to use a try/catch statement, you need to provide the catch part of the statement with an error parameter:
try {
// Do something
} catch (error) {
// Do something with 'error'
}
You have an incomplete try/catch statement. Go to that file and to that line, find a console.error in those brackets or something like that and add (error) (replace error with the object in console.error) just after catch and before {.
You have an old version of nodejs installed. To reinstall it to a newer one, use:
sudo apt-get purge --auto-remove nodejs
sudo apt-get update
sudo apt-get install build-essential libssl-dev
curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh
source ~/.profile
nvm install 14.17.4
I'm running Node.js server on Ubuntu 12.04. When I try to start server with node server.js I get
fs.js:438
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: EACCES, permission denied '/home/scadge/nodejs/server.js'
at Object.fs.openSync (fs.js:438:18)
at Object.fs.readFileSync (fs.js:289:15)
at Object.Module._extensions..js (module.js:473:44)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
I also tried sudo node server.js and sudo su followed by node server.js - in all cases I get the same error.
Try as below.
Its permission issue.
Open terminal
Go the project directory.
run chmod -R 777
On everything that is related with access denied can be fix with this.
Thank You.