node.js

Using a single websocket for a multiple clients

Using a single websocket for a multiple clients Question: I’ve never used before websockets neither web workers and everything around that. Obviously, I’m lost and I don’t know how to make it properly. I’ve learned how to make a websocket and leave it working in a server port successfully. As well, load a web worker …

Total answers: 1

NodeJS convert to Byte Array code return different results compare to python

NodeJS convert to Byte Array code return different results compare to python Question: I got the following Javascript code and I need to convert it to Python(I’m not an expert in hashing so sorry for my knowledge on this subject) function generateAuthHeader(dataToSign) { let apiSecretHash = new Buffer("Rbju7azu87qCTvZRWbtGqg==", ‘base64’); let apiSecret = apiSecretHash.toString(‘ascii’); var hash …

Total answers: 1

Python socket io client does'n accept connection but node client does

Python socket io client does'n accept connection but node client does Question: There is a node sever and I want to perform a socket connection with my client. I can connect with node but python version doesn’t connect. what is wrong with python version? const io = require(‘socket.io-client’); const socket = io("wss://winseller.turkmenexpress.ir", { auth: { …

Total answers: 2

VSCode python print object as object not string, similar to node.js

VSCode python print object as object not string, similar to node.js Question: VSCode, node.js script, run with debugger on and a breakpoint on the last line: const obj = { key1: ‘value1’, key2: ‘value2’ }; console.log(obj); console.log(JSON.stringify(obj)); console.log(”); produces this, in the interactive console: note the first output is the object in grey with the …

Total answers: 2

jsSHA and Python hashlib give different results for same input

jsSHA and Python hashlib give different results for same input Question: The following snippets use Nodejs and Python to calculate a hash from the same input content, but they give different results. It’s weird. // npm install jssha const jssha = require("jssha"); var s = new jssha("SHA-1", "TEXT"); s.setHMACKey("abc", "TEXT") s.update("123") console.log(s.getHMAC("B64")) The result is …

Total answers: 1

Can I install node.js 18 on Centos 7 and do I need python 3 install too?

Can I install node.js 18 on Centos 7 and do I need python 3 install too? Question: I’m not sure if node.js 18 supports centos 7 and is it a requirement to install python 3 for node.js 18? Asked By: Zachary Armstrong || Source Answers: Step 1 – curl –silent –location https://rpm.nodesource.com/setup_18.x | sudo bash …

Total answers: 3

Node.js install Python dependencies from within package.json

Node.js install Python dependencies from within package.json Question: I’m building a Node.JS project that uses both Python and NPM dependency modules. The Node.JS modules are located within package.json and the python dependencies are inside a file requirements.txt. I would like to install all the dependency modules (Python and Node.JS) from within package.json by running npm …

Total answers: 3

failed to build native modules on after node 16 upgrade and MacOS upgrade

failed to build native modules on after node 16 upgrade and MacOS upgrade Question: I’ve upgrade to MacOS Monterey (12.3.1) and Node 16. Since then I’m failed running installation on some node modules due to @newrelic/native-metrics with the following error: Error running install script for optional dependency: "/Users/zivl/github/data-science-client/serverless/ml-platform-services/node_modules/@newrelic/native-metrics: Command failed. Exit code: 1 Command: node …

Total answers: 2

Npm install error. 'npm ERR! gyp ERR! find Python, stack Error'

Npm install error. 'npm ERR! gyp ERR! find Python, stack Error' Question: Whenever I try to run npm install or npm update in my nuxt.js(vue.js) project, error below appears. npm ERR! code 1 npm ERR! path /Users/kyeolhan/ForWork/BackOffceFront/node_modules/deasync npm ERR! command failed npm ERR! command sh -c node ./build.js npm ERR! gyp info it worked if …

Total answers: 3

Python's zlib decompresses data, but Pako (JavaScript zlib) fails

Python's zlib decompresses data, but Pako (JavaScript zlib) fails Question: I’m trying to inflate some zlib compressed data (Ren’Py Archive 3 archive file structure for those wondering) with JavaScript, but I can’t seem to reproduce the Python behavior in Node.js. This Python script works: import zlib # Data written to a file from a different …

Total answers: 2