Crypto.randomBytes is not a function–an uncaught TypeError

See original GitHub issue

Hi there,

The error I am receiving: Crypto.randomBytes is not a function seems to derive from the ./~/es7-reflect-metadata/src/helper/gen-randombytes.ts file

gen-randonbytes.ts file includes:

import * as crypto from "crypto";
import {BufferLike} from "./interfaces";

export function genRandomBytes(size: number): BufferLike {
  return crypto.randomBytes(size); //Here is where the error occurs
}

I am running: es7-reflect-metadata: ^1.5.5, typescript: 1.7.5, angular2: 2.0.0-beta.7, npm: 3.8.0, node: 5.6.0

Thanks in advance for your help!

Simon

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sumigomacommented, Mar 1, 2016

Seeing the same error with latest changes, is es7-reflect-metadata missing a dependency on crypto (^0.0.3)?

https://github.com/gdi2290/es7-reflect-metadata/blob/master/package.json

0reactions
SimonHawesomecommented, Mar 2, 2016

Hooray!

On Tuesday, March 1, 2016, Yuki K notifications@github.com wrote:

Can confirm, latest polyfills and webpack config fixes the issue. Please close.

— Reply to this email directly or view it on GitHub https://github.com/AngularClass/angular2-webpack-starter/issues/365#issuecomment-191014522 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js crypto.randomBytes() is not a function
I ran into this same error in the command line: Uncaught TypeError: crypto.randomBytes is not a function. This did NOT work for me:...
Read more >
TypeError: crypto.randomBytes is not a function #150
When activating an experiment as follows: optimizelyClient.activate('experiment', 'user123') returns null and the logger shows this error ...
Read more >
Node.js crypto.randomBytes() Method
The crypto.randomBytes() method is used to generate a cryptographically well-built artificial random data and the number of bytes to be ...
Read more >
TypeError: crypto.randomBytes is not a function
Crypto object is being set as an empty object and that is the reason why randomBytes is not a function. But why? crypto...
Read more >
TypeError: crypto.randomBytes is not a function-node.js
This is my code where I am using rest password import crypto from 'crypto-js'; import { nanoid } from "nanoid"; userSchema.methods.
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