Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'crypto' #1053

Closed
sulthonzh opened this issue Jan 3, 2018 · 12 comments
Closed

Cannot find module 'crypto' #1053

sulthonzh opened this issue Jan 3, 2018 · 12 comments

Comments

@sulthonzh
Copy link

sulthonzh commented Jan 3, 2018

hello, i got error when require 'crypto'

==========================================================

code:
const crypto = require('crypto');

error result:
Cannot find module 'crypto'

==========================================================
is not crypto module supposed to by default already included?
but why this error got it?

thanks,

sorry, for this issue i write here.

this is my env:

{ 
test: '1.0.0',
npm: '5.6.0',
ares: '1.10.1-DEV',
cldr: '31.0.1',
http_parser: '2.7.0',
icu: '59.1',
modules: '57',
nghttp2: '1.25.0',
node: '8.9.4',
openssl: '1.0.2n',
tz: '2017b',
unicode: '9.0',
uv: '1.15.0',
v8: '6.1.534.50',
zlib: '1.2.11' 
}
@vsemozhetbyt
Copy link

How do you get the node binary and what OS do you use?

@sulthonzh
Copy link
Author

sulthonzh commented Jan 3, 2018

Hi @vsemozhetbyt, used Linux Ubuntu 16.04, and download binary with nvm install --lts

Is this strange?

@vsemozhetbyt
Copy link

As far as I know, if you have openssl (process.versions.openssl is defined), you also have crypto module, so it is strange to me. But I may be wrong, so let us wait till other answers.

cc @nodejs/crypto

@sulthonzh
Copy link
Author

sulthonzh commented Jan 3, 2018

@vsemozhetbyt who @nodejs/crypto, the page not found, I've asked the nodejs/node, but it was rejected.

i know @nodejs/crypto is private member, sorry.

@vsemozhetbyt
Copy link

@sulthonzh I've just mentioned the @nodejs/crypto group so that its members can chime in)

@mmarchini
Copy link

Couldn't reproduce it on Ubuntu 16.04 or 17.10 with Node 8.9.4 from nvm. @sulthonzh can you try to reinstall Node 8.9.4 to see if something went wrong during installation or if it's an environment problem? (remember to clear nvm cache before reinstalling it with nvm clear cache)

@tniessen
Copy link
Member

tniessen commented Jan 3, 2018

Yes, the crypto module should be available. What happens if you start the REPL by running node and then type crypto? It should print something like this:

F:\node>node
> crypto
{ DEFAULT_ENCODING: 'buffer',
  constants:
   { SSL_OP_ALL: 2147486719,
     SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: 262144,
     SSL_OP_CIPHER_SERVER_PREFERENCE: 4194304,
     SSL_OP_CISCO_ANYCONNECT: 32768,
     SSL_OP_COOKIE_EXCHANGE: 8192,
     SSL_OP_CRYPTOPRO_TLSEXT_BUG: 2147483648,
     SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: 2048,
     SSL_OP_EPHEMERAL_RSA: 0,
     SSL_OP_LEGACY_SERVER_CONNECT: 4,
     SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: 32,
     SSL_OP_MICROSOFT_SESS_ID_BUG: 1,
     SSL_OP_MSIE_SSLV2_RSA_PADDING: 0,
     SSL_OP_NETSCAPE_CA_DN_BUG: 536870912,
     SSL_OP_NETSCAPE_CHALLENGE_BUG: 2,
     SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: 1073741824,
     SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: 8,
     SSL_OP_NO_COMPRESSION: 131072,
     SSL_OP_NO_QUERY_MTU: 4096,
     SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: 65536,

@sulthonzh
Copy link
Author

image
this is my result node > crypto is working on node console,
but when require got error,

i have reinstall this but same,

@mmarchini
Copy link

As far as I understood, you're having problems when running a Casper test, right? Casper does not run on node, so this is not a Node issue. There's a related issue on Casper repository: https://github.com/casperjs/casperjs/issues/738, maybe it can help you :)

@sulthonzh
Copy link
Author

@mmarchini oh not careful, I have not read it, ok thanks for u reference,

@venkatesh-thatham
Copy link

I'm getting the same error after upgrade from Angular version 5 to 6.
when I try node > crypto is working on node console,
but when require got error.

below is my package.json

"dependencies": {
"@angular/animations": "6.0.0",
"@angular/common": "6.0.0",
"@angular/compiler": "6.0.0",
"@angular/core": "6.0.0",
"@angular/forms": "6.0.0",
"@angular/http": "6.0.0",
"@angular/platform-browser": "6.0.0",
"@angular/platform-browser-dynamic": "6.0.0",
"@angular/platform-server": "6.0.0",
"@angular/router": "6.0.0",
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.3",
"buffer": "^5.1.0",
"dotenv": "^5.0.1",
"ejs": "2.5.9",
"events": "^3.0.0",
"express": "4.16.3",
"fs": "0.0.1-security",
"http-status-codes": "^1.3.0",
"jsonwebtoken": "^8.2.1",
"nodemailer": "4.6.4",
"pg": "7.4.2",
"randomstring": "^1.1.5",
"rxjs": "6.1.0",
"sequelize": "4.37.6",
"stream": "0.0.2",
"timers": "^0.1.1",
"zone.js": "0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.6.3",
"@angular/cli": "^6.0.3",
"@angular/compiler-cli": "^6.0.3",
"@types/bcryptjs": "^2.4.1",
"@types/body-parser": "1.17.0",
"@types/dotenv": "4.0.3",
"@types/express": "^4.0.39",
"@types/jsonwebtoken": "7.2.7",
"@types/node": "10.0.4",
"@types/sequelize": "4.27.17",
"codelyzer": "4.3.0",
"concurrently": "^3.5.1",
"tslint": "5.10.0",
"typescript": "^2.7.2"
}

Please help

@adonahoe
Copy link

@thatham This gist resolved my issue, It's a hacky solution but might be worth a look:
https://gist.github.com/niespodd/1fa82da6f8c901d1c33d2fcbb762947d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants