close

[Fixed] Module not found: Error: Can’t resolve ‘crypto’

Today We are Going To Solve Module not found: Error: Can’t resolve ‘crypto’ in Javascript. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.

How to Fix Module not found: Error: Can’t resolve ‘crypto’ Error?

  1. How to Fix Module not found: Error: Can’t resolve ‘crypto’ Error?

    To Fix Module not found: Error: Can’t resolve ‘crypto’ Error just Add the below code to your package.json file. You have to just add the below code to your package.json file, right after the devDependencies section. It will solve the error.
    "devDependencies": { ... }, "browser": { "crypto": false }

  2. Module not found: Error: Can’t resolve ‘crypto’

    To Fix Module not found: Error: Can’t resolve ‘crypto’ Error just Add this setting in tsconfig.json file. Just add this setting in tsconfig.json file. It will solve your error completely. Just try this. "compilerOptions": { "baseUrl": "./", "paths": { "crypto": [ "node_modules/crypto-js" ] }

Solution 1 : Add the below code to your package.json file

You have to just add the below code to your package.json file, right after the devDependencies section. It will solve the error.

"devDependencies": {
    ...
},
"browser": {
    "crypto": false
}

Solution 2 : Add this setting in tsconfig.json file

Just add this setting in tsconfig.json file. It will solve your error completely. Just try this.

"compilerOptions": {
"baseUrl": "./",
"paths": {
  "crypto": [
    "node_modules/crypto-js"
  ]
}

Solution 3 : Try this crypto-js version

You have to try this crypto-js version to solve this error.

npm install [email protected]

Solution 4 : Add this to your webpack config file

Just add this to your webpack config file:

resolve: {
    fallback: { crypto: false },
},

Conclusion

So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.

Also Read These Solutions

Leave a Comment