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

184
Visualizações
browserify not working on basic html and basic js

I'm trying to create an simple web page to test the crypto module in js, but even when i use browserify my brower returns Uncaught ReferenceError: require is not defined.

My script.js:

const { createHash } = require('crypto');


function hasher() {
    const password = document.getElementById("js_n_password").value;
    const hash = createHash(password);
    document.getElementById("hashed").innerHTML = password;
}

My index.html:

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="style.css">
        <script src="bundle.js"></script>
        <script src="script.js"></script>
    </head>
    <body>


        <h1>Web Hash</h1>
        <form class="input" id="input">
            <label for="n_password">Password:</label>
            <input type="password" id="js_n_password" name="n_password">
        </form> 
        <button onclick="hasher()">hash it</button> 

        <p class="hashed" id="hashed"> </p>

    </body>
</html>

Why browserify isn't working and how can i make it work?

PS: add module.exports = function (n) { return n * 111 } to script.js doesn't change anything.

about 4 years ago · Juan Pablo Isaza
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