Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’

Change your file permissions… Like this First check who owns the directory ls -la /usr/local/lib/node_modules it is denying access because the node_module folder is owned by root drwxr-xr-x 3 root wheel 102 Jun 24 23:24 node_modules so this needs to be changed by changing root to your user but first run command below to check … Read more

MySQL 8.0 – Client does not support authentication protocol requested by server; consider upgrading MySQL client

Execute the following query in MYSQL Workbench ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’; Where root as your user localhost as your URL and password as your password Then run this query to refresh privileges: flush privileges; Try connecting using node after you do so. If that doesn’t work, try it without @’localhost’ part.

How to get the full URL in Express?

The protocol is available as req.protocol. docs here Before express 3.0, the protocol you can assume to be http unless you see that req.get(‘X-Forwarded-Protocol’) is set and has the value https, in which case you know that’s your protocol The host comes from req.get(‘host’) as Gopal has indicated Hopefully you don’t need a non-standard port … Read more

How, in general, does Node.js handle 10,000 concurrent requests?

If you have to ask this question then you’re probably unfamiliar with what most web applications/services do. You’re probably thinking that all software do this: user do an action │ v application start processing action └──> loop … └──> busy processing end loop └──> send result to user However, this is not how web applications, … Read more

Differences between socket.io and websockets

Misconceptions There are few common misconceptions regarding WebSocket and Socket.IO: The first misconception is that using Socket.IO is significantly easier than using WebSocket which doesn’t seem to be the case. See examples below. The second misconception is that WebSocket is not widely supported in the browsers. See below for more info. The third misconception is … Read more

How to access the GET parameters after “?” in Express?

So, after checking out the express reference, I found that req.query.color would return me the value I’m looking for. req.params refers to items with a ‘:’ in the URL and req.query refers to items associated with the ‘?’ Example: GET /something?color1=red&color2=blue Then in express, the handler: app.get(‘/something’, (req, res) => { req.query.color1 === ‘red’ // … Read more

Local dependency in package.json

npm >= 2.0.0 This feature was implemented in the version 2.0.0 of npm. Local paths can be saved using npm install -S or npm install –save, using any of these forms: ../foo/bar ~/foo/bar ./foo/bar /foo/bar Example package.json: { “name”: “baz”, “dependencies”: { “bar”: “file:../foo/bar” } } npm ls: app@0.0.1 /private/tmp/app └── somelocallib@0.0.1 -> /private/tmp/somelocallib npm … Read more

How can I wait In Node.js (JavaScript)? l need to pause for a period of time

Update Jan 2021: You can even do it in the Node REPL interactive using –experimental-repl-await flag $ node –experimental-repl-await > const delay = ms => new Promise(resolve => setTimeout(resolve, ms)) > await delay(1000) /// waiting 1 second. A new answer to an old question. Today ( Jan 2017 June 2019) it is much easier. You … Read more