question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expecting a finite number

See original GitHub issue

Given example

const cryptoRandomString = require('crypto-random-string');
cryptoRandomString({length: 10});

throws TypeError: expecting a finite number

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
philippboschcommented, Jan 3, 2021

I ran into the exact same problem and figured out what happened. Maybe this helps others.

Before I found this package, I initially installed the unique-string package which has a dependency on "crypto-random-string": "^2.0.0". When installing crypto-random-string npm apparently just used the already installed version instead of the latest available. So I ended up with version 2.0.0 for which the function signature is different, i.e. instead of something like { length: 10 } it expects just the length as an integer as the first argument. So when you pass it an object, it will fail with TypeError: Expected a finite number.

I fixed it by uninstalling both packages and re-instaling crypto-random-string. This gave me version 3.3.0.

0reactions
Edddo123commented, Mar 31, 2021

The answer @philippbosch wrote is correct. The problem is in versioning. The easier solution would be just to install this module at specific version. npm install crypto-random-string@3.3.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

isFinite() - JavaScript - MDN Web Docs - Mozilla
The global isFinite() function determines whether the passed value is a finite number. If needed, the parameter is first converted to a number....
Read more >
Expected value - Wikipedia
The expected value of a random variable with a finite number of outcomes is a weighted average of all possible outcomes. In the...
Read more >
passport-local strange error: "Expected a `length` to be a non ...
node. js - passport-local strange error: "Expected a `length` to be a non-negative finite number" - Stack Overflow. Stack Overflow for Teams – ......
Read more >
Expected Value of X - Finite Math - YouTube
See more problems and solutions at http://finitehelp.comI participated in a free-throw shooting charity, and my sponsor pays $10 for each ...
Read more >
MTH 143 Random Variables and Expected Values (Finite Math)
MTH 143 Random Variables and Expected Values ( Finite Math). Watch later. Share. Copy link. Info. Shopping. Tap to unmute.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found