Categories
TypeScript Answers

How to fix Module not found: Error: Can’t resolve ‘crypto’ with TypeScript?

Spread the love

Sometimes, we want to fix Module not found: Error: Can’t resolve ‘crypto’ with TypeScript.

In this article, we’ll look at how to fix Module not found: Error: Can’t resolve ‘crypto’ with TypeScript.

How to fix Module not found: Error: Can’t resolve ‘crypto’ with TypeScript?

To fix Module not found: Error: Can’t resolve ‘crypto’ with TypeScript, w e add a reference to the crypto library in tsconfig.json.

For instance, we write

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

to set the path to the crypto module in the tsconfig.json file in the compilerOptions.paths JSON property.

Conclusion

To fix Module not found: Error: Can’t resolve ‘crypto’ with TypeScript, w e add a reference to the crypto library in tsconfig.json.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *