Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

255
Vistas
Notification - Electron Error - _crypto.default.randomFillSync is not a function

I try to use notify in my electron project on node server. So i installed node-notifier module in my app folder using the following command.

  $ npm install --save node-notifier

After that i add button to the my web page to show notify message.
When the button is clicked by user then below js method is ran:

<script type = "text/javascript">
         const notifier = require('node-notifier')
         const path = require('path');
         
         document.getElementById('notify').onclick = (event) => {
            notifier.notify ({
               title: 'My awesome title',
               message: 'Hello from electron, Mr. User!',
               icon: path.join('','images/images.png'),  // Absolute path (doesn't work on balloons)
               sound: true,  // Only Notification Center or Windows Toasters
               wait: true    // Wait with callback, until user action is taken against notification
            }, function (err, response) {
               // Response is response from notification
            });

            notifier.on('click', function (notifierObject, options) {
               console.log("You clicked on the notification")
            });

            notifier.on('timeout', function (notifierObject, options) {
               console.log("Notification timed out!")
            });
         }
      </script>

But when i click my notify button i get the error like as below:

Uncaught TypeError: _crypto.default.randomFillSync is not a function
        rng @ Project\MyElectronProject\node_modules\uuid\dist\rng.js:19
        v4  @ Project\MyElectronProject\node_modules\uuid\dist\v4.js:17
        getPipeName @ Project\MyElectronProject\node_modules\node-notifier\notifiers\toaster.js:51
        notifyRaw@ Project\MyElectronProject\node_modules\nodenotifier\notifiers\toaster.js:60
        document.getElementById.onclick @notification_index.html:16 

Above error is thrown rng function in rng.js.

function rng() {
  if (poolPtr > rnds8Pool.length - 16) {
    debugger;
    _crypto.default.randomFillSync(rnds8Pool);

    poolPtr = 0;
  }

randomFillSync method is not exist. I can't understand this error, have you encountered this error before ? Thanks for your suggestions.

node version that i used in my project: v16.13.1

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

node-notifier is a nodejs module, can't be used in browser script.

i think you should call node-notifier in main process, and then communicate from a renderer process to the main process.

Please refer: https://www.electronjs.org/docs/latest/api/ipc-renderer

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda