Node.js qrcode library issue - node.js

I have reinstalled my web app in a new server without changing anything and now I receive this error:
TypeError: QRCode.drawBitArray is not a function
why? i haven't change my code....
this is the library : https://github.com/simwood/node-qrcode
and yess, i have install all the dependencies.
alternatively, do I recommend libraries that return an array with the length of the line?
sorry for bad english(:

drawBitArray has been removed in the last version of qrcode.
The official repo seems to be here and the last version with the function is 0.7.1.
In the last version (at this time 1.4.4) you can obtain the array of bits and the size returned by drawBitArray this way:
const myQrCode = qrcode.create("myContent")
const bits = new Uint8Array(myQrCode.modules.data)
const QrLineSize = myQrCode.modules.size

run this npm install --save node-qrcode
if that doesnt work try deleting node_modules folder and running that command again.
also check the version of node-qrcode that are installed in your package.json file. make sure theyre consistant with eachother

Related

TypeError: parse is not a function

As I had installed the Font Awesome dependencies to my app and tried to run npm start right after to test it out, I received this error and it has been super brutal & difficult to resolve.
$ npm start
> portfolio#0.1.3 start
> react-scripts start
~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/css-select/lib/compile.js:31
var token = parse(selector, options);
^
TypeError: parse is not a function
at compileUnsafe (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/css-select/lib/compile.js:31:14)
at Function.compile (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/css-select/lib/compile.js:20:13)
at new Selector (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/renderkid/lib/renderKid/styles/rule/Selector.js:13:26)
at new Rule (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/renderkid/lib/renderKid/styles/Rule.js:10:21)
at StyleSheet.module.exports.StyleSheet._setSingleRule (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/renderkid/lib/renderKid/styles/StyleSheet.js:42:14)
at StyleSheet.module.exports.StyleSheet._setRule (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/renderkid/lib/renderKid/styles/StyleSheet.js:33:12)
at StyleSheet.module.exports.StyleSheet.setRule (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/renderkid/lib/renderKid/styles/StyleSheet.js:22:14)
at Styles.module.exports.Styles._setDefaultStyles (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/renderkid/lib/renderKid/Styles.js:34:25)
at new Styles (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/renderkid/lib/renderKid/Styles.js:30:10)
at RenderKid.module.exports.RenderKid._initStyles (~/Documents/GitHub/REACT/Portfolio/Portfolio/node_modules/renderkid/lib/RenderKid.js:53:27)
I've checked my package.json file and have my start scripts assigned correctly. I have been at it with this error for nearly a day already.
I have also checked on all my dependencies to make sure they were not outdated. Everything is up to date and still seems to be getting the error.
I have even tried to revert back a few steps from my commits but unfortunately still running into this error so I believe it has to to something with the modules
Try to use an older stable version instead of the new version.
It worked for me..
I changed the version in packet.json and removed node_module folder and
then use npm install again

'private: true' and 'lsd: false' not recognised as valid torrent options, won't allow torrent to be converted to private. NodeJS | WebTorrent

What version of this package are you using?
webtorrent#0.107.17
webtorrent-hybrid#4.0.2
What operating system, Node.js, and npm version?
OS: Linux Lite 5 (64 bit)
Node.js: 14.15.1
npm: 6.14.8
What happened?
I normally initialised a client by following the docs. Like so:
this.webTorrentClient = new WebTorrentHybrid({tracker: true, dht: true});
However, I simply wanted to switch my torrent to private so that it won't publish to DHT, PEX and LSD. I specifically have a requirement to disable LSD. Again I followed the docs, added opts and put in the private flag like so:
this.webTorrentClient.add(magnetUri, {private: true}, (torrent) => {
//did my task here
});
On doing that weirdly I was greeted with this error stating that this particular property doesn't exist in torrent options
Argument of type '{ private: boolean; }' is not assignable to parameter of type 'TorrentOptions'.
Object literal may only specify known properties, and 'private' does not exist in type 'TorrentOptions'
On facing this error, I initially figured that maybe opts for WebTorrentHybrid are different from WebTorrent but when I fetched the docs they stated that it's exactly the same. I then tried putting private: true in the .seed method instead, but received the same error.
Alternatively I figured, that since I only want LSD to be disabled and digging through the commit history I found that an option to disable LSD has also been added. (With reference to this commit ID here: https://github.com/webtorrent/webtorrent/commit/0ba67b8e8f54d888ba0dd14a6e5f4a18d46e1294). So I tried putting lsd: false in both .add and .seed but again no dice. Same error.
At this point I felt that maybe I am passing opts in the wrong format but on trying other opts. They worked just fine. I tried putting path: '/mnt/drive1/' in both .add and .seed like so:
this.webTorrentClient.add(magnetUri, {path: '/mnt/drive1/'}, (torrent) => {
//did my task here
});
And it worked absolutely fine, similarly I tried maxWebConns: 3 and that too worked! For some reason only private and lsd don't seem to be working in my case. Quick google search showed that no one else had a similar problem and I was left confused!
I have been following the official docs from here: https://webtorrent.io/docs
For anyone facing the same issue. I solved the above issue by manually updating the following packages by using these commands:
npm update --save/--save-dev
npm install webtorrent#latest --save-dev
npm install #types/webtorrent#latest --save-dev
I had in my quest to solve this issue, run npm update --save/--save-dev several times. But for some reason these packages hadn't been updated even when there weren't any breaking changes. Realising they were outdated by running npm outdated and then manually updating by using the commands above solved it!

dyld: Symbol not found: _napi_module_register

Had my node working with the VS Code debugger last night no problem. I haven't touched anything besides install the npm mysql package.
I come back tonight and its throwing this error:
Debugger listening on [::]:49952
dyld: lazy symbol binding failed: Symbol not found: _napi_module_register
Referenced from: /Users/adamsawyers/node_modules/bufferutil/prebuilds/darwin-
x64/node-napi.node
Expected in: flat namespace
dyld: Symbol not found: _napi_module_register
Referenced from: /Users/myusername/node_modules/bufferutil/prebuilds/darwin-
x64/node-napi.node
Expected in: flat namespace
Apparently my installation of n (a node version handling package in npm) is busted somehow. My research told me that napi_module_register is part of the n package, but I'm not sure how this got messed up especially since I had it working last night.
I tried reinstalling my node packages, reinstalling n, rebuilding the project file structure, even restarting my computer. Nothing has worked so far.
Any suggestions?
Apparently VS code doesn't like v6.10.3 of nodejs which I am running to create lambda functions in AWS (that is the version specified by AWS)
I use the N package to manage my node version. After switching to the latest version 10.7.0 as of 07/25/2018 (command: sudo n latest) and rerunning the debugger in VS code, it worked perfectly
I'm still unsure as the the cause, but hopefully others find this solution helpful
This exact error happened to me because:
I needed socket.io to run on Node
Which in turn needs ws (websockets on Node)
Also, I needed to run this on an outdated Node version (Node 7) for a very good reason (believe me, I would not want to do this if I wouldn't have to)
However, trying to use it on that old version causes above error message.
Solution
This is a terrible solution, but at least I got it to work.
After some researching, I found no good solution to this. However, a close look at the source code shows that there is a fallback.js next to index.js which implements the same functionality as the native build but without needing a build. This will probably slow things down significantly, but at least it works:
yarn add module-alias
prefix your actual code with this (e.g. via node -r fallbacks.js):
// fallbacks.js
const moduleAlias = require('module-alias');
const dependencyRoot = getDependencyRoot(); // whatever is your root folder, maybe __dirname + '..'
moduleAlias.addAlias('bufferutil', dependencyRoot + '/node_modules/bufferutil/fallback.js');
moduleAlias.addAlias('utf-8-validate', dependencyRoot + '/node_modules/utf-8-validate/fallback.js');
// run actual code here...
PS: In my case, in order to allow ws to run on Node 7, I also had to babel it, since its using modern synytax.

Node.js module is looking for node-modules instead of node_modules

I have the following based on instructions from here:
const Pubgapi = require('pubg-api');
const apiInstance = new Pubgapi('api-key');
For some reason when I run it, the console says unable to resolve path but it's looking for a node-modules which I don't have. This is an API wrapper that I am trying to use by the way. What could cause it to give me this error?
I did an npm install as the instructions said and nothing else before the statements above.
Error message:
Unable to resolve ../node-modules/pubg-api" from ".//components/Main.js`: The module `../node-modules/pubg-api` could not be found"
I have checked the node_modules folder. It is indeed pubg-api, not pubg_api. Requiring pubg_api gives me this error.
This error is probably related to the HTTPS library that the library you are trying to install depends on. Node.js libraries are not compatible with react-native since it is not working on a Node.js platform.
To overcome this issue you can try to use react-native-http library, but I did not try to use it before, so I'm not sure if it's going to work or not.

Exception could not locate binding file after updating electron version

I'm working on updating my project from using electron version 1.2.5
to the newest electron at this time which is 1.7.7 (atleast it was when I downloaded it). My node version 6.9.1.
I've encountered a problem when I start my project with this new electron version,
the error in general is about "could not locate the binding files. and it mostly regards the async module.
There is also some part of the exception regarding node-etcd module which I use in my project (version 5.0.3)
I found some information about this type of exception online but most of them says stuffs about rebuilding some node module using some npm commands which I didn't quiet understand. I tried to install async module again in a new folder and replace it (with its deps) in the node modules folder im currently using for my project, but I still got the same error.
I'm working in an offline enviorment where I can't take my project "out" to a computer with internet access, I can only bring things from the web to my project (like installing in some folder and then copying that into my project) so any npm or other commands that require web connection are not available to me directly on my work computer. (I can only use them in a different computer and copy the results to a flash drive and bring them to th
Here's 2 pictures of the error (sorry about the quality, its the best I could get):
First part of error
Second part of error
The solution that fixed the problem in my case was going into node_modules - > deasync - > index.js
Before line 31 I added a newline (next to the binding line)
and wrote:
modPath = __dirname;
This solution is hacky, it was accually ly found by an associate a while back, so I am not sure why it works, it might be an issue in deasync, but it fixed the problem.

Resources