how to install Socket.io over node.js? - javascript

I will need any help i can get to install socket.io over node.js for server.
I have already installed the node from the site. I am interested in step- by step(directory,e.t.c) as i am new to programming.
Thanks in advance
James

The easy way to install socket.io is with npm (Node Package Manager). npm is the default package manager for Node.js.The current Windows installer from nodejs.org will install npm along with Node.js. In Windows OS, open the cmd window and type:
npm install socket.io
This command will install socket.io in the local node_modules folder, which is owned by the current user.
npm can also take optional flags which are described at the npm-install webpage of www.npmjs.org.
In order to test if socket.io is working, try this tutorial: Get Started: Chat application which has been linked to by Beterraba in a comment below your question.

Related

"Error: FFMPEG not found": Error with simple Discord Bot

I'm using Windows (64-bit) with Node.js and npm installed.
In my project file, I have run the following commands:
npm init
npm install discord.js --save
npm install ffmpeg --save
Now i just created the code for a basic bot here is the main code.
I list here the important:
if (message.content === '!play' && message.member.roles.has(message.guild.roles.find("name", config.role_name).id)) {
if (!message.member.voiceChannel) return log("?");
message.member.voiceChannel.join().then(function (connection){
});
}
Then, in Discord, I say the following:
[1517932146] Musik bot loaded
(node:35760) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: FFMPEG not found
I have already tested the following:
reinstallation of everything
others of the require names e.t.z.
simplify the code
So if you have any ideas then let me know.
Solution
npm i ffmpeg-binaries#3.2.2-3
link
You need to actually install ffmpeg, the ffmpeg module on NPM simply exports a wrapper API for ffmpeg's command-line interface.
You can download ffmpeg's binaries from the website or use a package manager (like apt on Ubuntu, brew on Mac or choco on Windows) which usually takes care of dropping the binaries into a directory that is present in the PATH.
To install on windows using choco. Please ensure you running cmd/windows powershell/ windows terminal as administrator or it will fail here ...
choco install ffmpeg
To install on linux
sudo apt install ffmpeg
As far as I can see, you never actually installed ffmpeg. Using the ffmpeg node module won't get you anywhere unless you install the binaries.
You can also use apt, brew or in your case choco which makes things go alot faster. Here is a guide on how to do it in windows.
Once it is installed you will be able to use many node modules such as opusscript and much more.

How to migrate a proxy NPM repository in Nexus 3?

I have a Nexus 3 installation with these NPM repos defined:
npm-all (group)
npm-internal (hosted)
npmjs-org (proxy)
I would like to be able to populate the npm proxy repository on an Internet connected machine, and then migrate it to a Nexus Server running on a disconnected machine. Nexus 3 has a Task to backup/restore the entire underlying Orient database, but I can't find a way to do it for a specific repository. My goal is to have a npm proxy repo that's populated with NPM packages I need, in an offline environment.
As far as I know there is no way to do this with any built in mechanism. Your best bet is to publish all packages you need to a hosted repository or alternatively just have the proxy repo and server connected to the internet during provisioning but take it offline afterwards.
You can use this npm tool.
Using this tool download the artifacts from the repositories and upload them in the offline server
Disclaimer, I’m the author of this package

OpenVPN with node, How it works?

I am able to connect to a VPN from terminal easily with the following openVPN command:
openvpn --config conf.ovpn
I need connect to the same VPN with Javascript (for selenium test), I already have installed openvpn.client with NPM:
npm install openvpn-client
However, I don't know how it works. I would like how to achieve a terminal application with similar functionalities of openvpn.
Documentation and source code
https://www.npmjs.com/package/openvpn-client
https://github.com/resin-io/openvpn-client
Solved, more or less...
After install openvpn in the system just add bit s to the openvpn bin (sudo chmod +s /usr/sbin/openvpn), then you can connect openvpn with this:
var exec = require("child_process").exec;
cmd = `openvpn --config ${conf.ovpn}&`;
exec(cmd);
Just that. Maybe isn't the most secure solution, but it works for my purpose.
Thanks.

Meteor js Windows install error "Failed to contact install server"

I have tried running the install with "Run as Admin" feature on windows too, but the same issue persists.
I see this question has been posted before but still no resolution given.
Basically the following error message comes in the middle of the install and the install stops. Please help.
Error message:
"Failed to contact install server. Please try again later."
Check if you have Node js already installed before installing meteorjs other wise it crashes on Windows sometimes hope it helped.
https://nodejs.org/en/download/
Install meteor with this installer: https://github.com/meteor/meteor/wiki/Preview-of-Meteor-on-Windows
If you are behind a proxy set these parameters HTTP_PROXY and HTTPS_PROXY: Using Meteor behind a proxy
Update your meteor installation: meteor update
The meteor will be updated to the last version.
install from https://github.com/meteor/meteor/wiki/Preview-of-Meteor-on-Windows (the >60MB file) and set the user.meteor folder in your path
the problem with windows installation is too long pathnames (>256) so better try a linux VM

Installing node.js for angular - connect.static and karma

I'm trying to install a simple node webserver following the example in Pro AngularJS from apress.
I've installed node.js and the connect and karma modules.
I do get a warning when I installed karma via: "npm install -g karma" that says "optional dep failed, continuing" but then seems to install correctly.
I created a server.js based on the example:
var connect = require('connect');
connect.createServer(
connect.static("../angularjs")
).listen(5000);
when I run it I get TypeError:Undefined is not a function pointing to connect.static.
Apparently in the latest build of connect the static middleware has been moved to it's own package.
nodejs connect cannot find static

Categories