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.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.