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

web3.js crypto from node_modules/web3-eth-accounts/src/index.js`: Module does not exist in the module map #1095

Closed
ghost opened this issue Oct 7, 2017 · 12 comments

Comments

@ghost
Copy link

ghost commented Oct 7, 2017

error: bundling failed: UnableToResolveError: Unable to resolve module crypto from node_modules/web3-eth-accounts/src/index.js: Module does not exist in the module map

@TonyFrancis
Copy link

@vivekebics I am facing same issue

@dacarley
Copy link
Contributor

Could you provide more context about the issue? What are you using for bundling? Can you provide a minimal project that demonstrates the problem?

@KSanthanam
Copy link

I can see where the problem is. But don't know how to fix this.
web3-eth-accounts sources crypto module, but does not include in package.json. I can't find crypto module in npm either.
in line 34 of node_mdoules/web3-eth-accounts/src/index.js
var cryp = require('crypto');
but package.json of web3-eth-accounts is

{
"_args": [
[
"web3-eth-accounts@1.0.0-beta.24",
"/Users/KK/ggit/react/kyc-blockchain"
]
],
"_from": "web3-eth-accounts@1.0.0-beta.24",
"_id": "web3-eth-accounts@1.0.0-beta.24",
"_inBundle": false,
"_integrity": "sha1-Ab669zmoXhZScjCDQ36UobxDWzg=",
"_location": "/web3-eth-accounts",
"_phantomChildren": {
"bn.js": "4.11.8",
"elliptic": "6.4.0",
"xhr-request-promise": "0.1.2"
},
"_requested": {
"type": "version",
"registry": true,
"raw": "web3-eth-accounts@1.0.0-beta.24",
"name": "web3-eth-accounts",
"escapedName": "web3-eth-accounts",
"rawSpec": "1.0.0-beta.24",
"saveSpec": null,
"fetchSpec": "1.0.0-beta.24"
},
"_requiredBy": [
"/",
"/web3-eth"
],
"_resolved": "https://registry.npmjs.org/web3-eth-accounts/-/web3-eth-accounts-1.0.0-beta.24.tgz",
"_spec": "1.0.0-beta.24",
"_where": "/Users/KK/ggit/react/kyc-blockchain",
"dependencies": {
"bluebird": "3.3.1",
"eth-lib": "0.2.5",
"scrypt.js": "0.2.0",
"underscore": "1.8.3",
"uuid": "2.0.1",
"web3-core": "^1.0.0-beta.24",
"web3-core-helpers": "^1.0.0-beta.24",
"web3-core-method": "^1.0.0-beta.24",
"web3-utils": "^1.0.0-beta.24"
},
"description": "Web3 module to generate Ethereum accounts and sign data and transactions.",
"license": "LGPL-3.0",
"main": "src/index.js",
"name": "web3-eth-accounts",
"namespace": "ethereum",
"repository": {
"type": "git",
"url": "https://github.com/ethereum/web3.js/tree/master/packages/web3-eth-accounts"
},
"version": "1.0.0-beta.24"
}

@connectdotz
Copy link

it's using node.js build-in crypto library, which means you will need to do something "special" to get it working outside of node.js... not sure this is a solved problem right now as far as I can tell...

@KSanthanam
Copy link

Solved this issue by adding the crypto directive for react-native in package.json
"react-native": {
"zlib": "browserify-zlib",
"console": "console-browserify",
"constants": "constants-browserify",
"crypto": "react-native-crypto",
}

@seymoe
Copy link

seymoe commented Jul 7, 2018

@KSanthanam can u tell me why I can't solve this problem with your opinion?
adding the crypto directive for react-native in package.json

"react-native": {
"zlib": "browserify-zlib",
"console": "console-browserify",
"constants": "constants-browserify",
"crypto": "react-native-crypto",
}

I had installed web3 and added those code in package.json, but also didn't work, I tried remove node_modules folder and installed again, and clear watchman and so on, just didn't work,

It's terrible! could u help me?

@seymoe
Copy link

seymoe commented Jul 7, 2018

I just find the solution in this url https://gist.github.com/dougbacelar/29e60920d8fa1982535247563eb63766

@ethereumdegen
Copy link

I think it is because a dependency is 'scrypt.js' when it really should be 'scrypt' ... ?

@nivida
Copy link
Contributor

nivida commented Aug 9, 2018

This issue is not directly related to web3.js and because of that I will closing it. It's described here https://gist.github.com/dougbacelar/29e60920d8fa1982535247563eb63766 how to set up web3.js for react native.

@elanpang
Copy link

elanpang commented Oct 6, 2018

this issue happened again with RN 0.57.1

@ameshkin
Copy link

ameshkin commented Jan 3, 2020

"zlib": "browserify-zlib",
"console": "console-browserify",
"constants": "constants-browserify",
"crypto": "react-native-crypto",

This did not work for me???

@Akash9923
Copy link

Akash9923 commented Jul 30, 2021

plugins: [
[
'module-resolver',
{
root: ['.'],
alias: {
crypto: 'react-native-crypto',
},
},
],
],

add this babel.config.js file for react native

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

10 participants