Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

320
Visualizações
Module not found: Error: Can't resolve 'crypto' in

Error Message:

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.

So I was googling this issue and had a LOT of problems finding a solution. So i would like to share it with you:

  1. First of all this can happen not only with crypto but other stuff like http, https, os and so on.

  2. Check if the packet (this case crypto-browserify is installed) There should be a folder node_modules\crypto-browserify

If it doesnt exist: npm install crypto browsrify, then yarn add @types/node@15.12.5 -D (for this node version)

In node_modules\crypto-browserify edit package.json and add

 , 
 "optionalDependencies": {},
 "browser": {
   "crypto": false
 },

(after devDependencies)

  1. under tsconfig.json add
"compilerOptions": {
"paths":{
   "crypto":["node_modules/crypto-browserify"],
   "http":["node_modules/stream-http"],
   "https":["node_modules/https-browserify"]
   },
  1. under angluar.json add
"architect": {
   "build": {
   "builder": "@angular-devkit/build-angular:browser",
   "options": {
      "allowedCommonJsDependencies": ["crypto"],
      "allowedCommonJsDependencies": ["http"],
      "allowedCommonJsDependencies": ["https"],
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I had this problem in ReactJS with create-react-app(facebook)

Solution:

  1. First install the necessary packages "crypto-browserify"

  2. Modify webpack.config.js in reactjs with create-react-app this file is inside:

node_modules/react-scripts/config/webpack.config.js

  • Search module.exports and inside this function there is a return:
module.exports = function (webpackEnv) {
  ...
  return {
   ...
    resolve: {
      ...
      fallback: {
        // Here paste
        crypto: require.resolve("crypto-browserify"),

      }
    }
  }
}

Note:Is possible that need more packages, for example "stream-browserify" the steps are same. This solution works, but when the webpack project starts it shows warnings

Pd: I am not native speaker English, but I hope understand me.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda