node.js
Jest testing multiple test file port 3000 already in use
Jest runs test suites in parallel by default. However, the machine that the tests are running on only has a single port 3000 (or port 4000, etc.) This means that if you tell your app to listen on a port, and then start multiple concurrent processes, there will be a port collision and Jest will … Read more
Yarn cache takes a lot of space
Yarn website says the following:- Yarn stores every package in a global cache in your user directory on the file system. You can use yarn cache list & it will print out every cached package. Just in case you wanted to go through. You can use yarn cache clean & it will clean the cache … Read more
Difference between req.url and req.originalUrl in Express.js version 4
From the Express.js documentation: req.url is not a native Express property, it is inherited from Node’s http module. This property is much like req.url; however, it retains the original request URL, allowing you to rewrite req.url freely for internal routing purposes. For example, the “mounting” feature of app.use() will rewrite req.url to strip the mount … Read more
Reference file in public folder from CSS in create-react-app
Just use a / before the name, this will make it relative to the output root, which includes anything in the public folder (provided the finished hosted application is served at the root of a domain). so for the question asked above: .App-header { background-color: #222; height: 150px; padding: 20px; color: white; background-image: url(“/example.png”); } … Read more
NodeJS UDP Multicast How to
Changed: client.addMembership(‘230.185.192.108’); to client.addMembership(‘230.185.192.108’,HOST); //Local IP Address
What could cause “connect ETIMEDOUT” error when the URL is working in browser?
When behind a proxy you need to make the following modifications (as explained in this answer): put the proxy host in the host parameter put the proxy port in the port parameter put the full destination URL in the path parameter : Which gives: var options = { host: ‘<PROXY_HOST>’, port: ‘<PROXY_PORT>’, path: ‘http://www.boardgamegeek.com/xmlapi/boardgame/1?stats=1’, method: … Read more
node.js – handling TCP socket error ECONNREFUSED
I ran the following code: var net = require(‘net’); var client = net.connect(5558, ‘localhost’, function() { console.log(“bla”); }); client.on(‘error’, function(ex) { console.log(“handled error”); console.log(ex); }); As I do not have 5558 open, the output was: $ node test.js handled error { [Error: connect ECONNREFUSED] code: ‘ECONNREFUSED’, errno: ‘ECONNREFUSED’, syscall: ‘connect’ } This proves that the … Read more