This repository was archived by the owner on Feb 12, 2024. It is now read-only.
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
ReferenceError: crypto is not defined #3845
Closed
Description
-
Version:
0.58.2 -
Platform:
5.4.0-81-generic # 91-Ubuntu SMP Thu Jul 15 19:09:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Severity:
High - The main functionality of the application does not work, API breakage, repo format breakage, etc.
Description:
When starting up an ipfs node I get this error:
error: ReferenceError: crypto is not defined
at Hasher.encode (/home/hunter/Documents/projects/ipfsTest/node_modules/multiformats/cjs/src/hashes/sha2-browser.js:7:56)
at Hasher.digest (/home/hunter/Documents/projects/ipfsTest/node_modules/multiformats/cjs/src/hashes/hasher.js:16:35)
at RsaPublicKey.hash (/home/hunter/Documents/projects/ipfsTest/node_modules/libp2p-crypto/src/keys/rsa-class.js:45:36)
at computeDigest (/home/hunter/Documents/projects/ipfsTest/node_modules/peer-id/src/index.js:242:19)
at computePeerId (/home/hunter/Documents/projects/ipfsTest/node_modules/peer-id/src/index.js:247:24)
at Function.exports.createFromPrivKey (/home/hunter/Documents/projects/ipfsTest/node_modules/peer-id/src/index.js:331:10)
at async configureRepo (/home/hunter/Documents/projects/ipfsTest/node_modules/ipfs-core/src/components/storage.js:227:18)
at async loadRepo (/home/hunter/Documents/projects/ipfsTest/node_modules/ipfs-core/src/components/storage.js:81:17)
at async Function.start (/home/hunter/Documents/projects/ipfsTest/node_modules/ipfs-core/src/components/storage.js:59:41)
at async Object.create (/home/hunter/Documents/projects/ipfsTest/node_modules/ipfs-core/src/components/index.js:260:21)
Steps to reproduce the error:
test.js:
const IPFS = require('ipfs');
let ipfsNode;
async function startMainConnection() {
ipfsNode = await IPFS.create().catch(error => {
console.error('error:', error);
});
}
startMainConnection();
package.json:
{
"dependencies": {
"ipfs": "^0.58.2"
}
}
Run node test.js
and you'll get the same error.
I've also zipped this replication project and attached it:
ipfsTest.zip
Open the file and run npm i
then node test.js
to get the same error.