close

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

Hello Guys, How are you all? Hope You all Are Fine. Today I am getting the following list of errors when I run ng serve Module not found: Error: Can’t resolve ‘crypto’ in Javascript. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

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

I am getting the following list of errors when I run ng serve. The error I get :

ERROR in ./node_modules/aws-sign2/index.js Module not found: Error: Can't resolve 'crypto' in '/Users/MYPC/Documents/Myproj/ProName/node_modules/aws-sign2' 

ERROR in ./node_modules/aws4/aws4.js Module not found: Error: Can't resolve 'crypto' in '/Users/MYPC/Documents/Myproj/ProName/node_modules/aws4' ERROR in ./node_modules/ecc-jsbn/index.js

How To Solve Module not found: Error: Can’t resolve ‘crypto’ Error ?

  1. How To Solve Module not found: Error: Can't resolve 'crypto' Error?

    To Solve Module not found: Error: Can't resolve 'crypto' Error Just add the “crypto”: false to the package.json file, right after the devDependencies section.

  2. Module not found: Error: Can't resolve 'crypto'

    To Solve Module not found: Error: Can't resolve 'crypto' Error Just add the “crypto”: false to the package.json file, right after the devDependencies section.

Solution 1: add the following to the package.json

Just add the following to the package.json file, right after the devDependencies section.

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

Solution 2: Add this setting in tsconfig.ts

Just add this setting in tsconfig.ts file under that project to resolve this warning

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

Solution 3: Set “crypto”: false

If you don’t want to use crypto then you’ll have to set to false any dependencies that are showing up in “can’t resolve x” errors. For example, the critical part of my package.json is:

    "browser": {
        "crypto": false,
        "

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

Please Rate Our Solution to Motivate Us For Give Our Best

Leave a Comment