Expecting a finite number
See original GitHub issueGiven example
const cryptoRandomString = require('crypto-random-string');
cryptoRandomString({length: 10});
throws TypeError: expecting a finite number
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 installingcrypto-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 withTypeError: Expected a finite number
.I fixed it by uninstalling both packages and re-instaling
crypto-random-string
. This gave me version 3.3.0.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