안광섭
안광섭

Reputation: 51

importing a node module create an error

I imported node module 'request' in app.js but as soon as my script read,

var request = require('request'); 

it creates an error like below. Anyone has an idea?

Error Message:

[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()

Upvotes: 5

Views: 2276

Answers (1)

Chris Foster
Chris Foster

Reputation: 2649

request depends on the library node-uuid. 'node-uuid' is used for generating random UUID's, also called GUID's.

To get truly random UUID's, node-uuid requires a cryptographically secure random source. Normally it will use crypto.randomBytes (in node) or crypto.getRandomValues (in the browser), but if that does not exist it will fall back to Math.Random. However, Math.random cannot generate cryptographically secure random numbers (read here for more info).

Request uses UUID's for its OAuth nonces and multipart file uploads. If you use OAuth, not having secure random nonces may be a security concern.

The crypto module should be present in all node installations (to my knowledge), so it's likely that you are running this code in a web browser environment. You may be running in a web browser that doesn't support the crypto module quite yet, and therefore Math.random is really your only option. You can check the can i use page to see if your browser supports getRandomValues.

Upvotes: 5

Related Questions