'Require.js Module name * has not been loaded yet for context

https://github.com/vankasteelj/torrent-tracker-health

I have followed the installation steps, however it is unclear to me how to use that library for my needs.

I ended up using require.js, but had no luck..

At the end, I would need to input these variables which are now displayed in console.log to MySQL database. I can do that myself if this error didn't prevent me:

Errors

Uncaught Error: Module name "torrent-tracker-health" has not been loaded yet for context: _. Use require([])

index.php

<!DOCTYPE html>
<html lang="en">
  <head>
    <script data-main="scripts/app" src="scripts/require.js"></script>
  </head>
    <body>
      
      <script>
        var torrentHealth = require('torrent-tracker-health');
        var magnet = 'magnet:?xt=urn:btih:9A7290F4021048D2C176A84828E441FCB5400FB1&dn=charlie+chaplin+15+short+films+1914+1917+dvdrip&tr=udp://tracker.coppersurfer.tk:6969/announce&tr=udp://glotorrents.pw:6969/announce&tr=udp://tracker.openbittorrent.com:80/announce';

        torrentHealth(magnet).then(function (res) {
            console.log('seeds:', res.seeds);
            console.log('peers:', res.peers);
            console.log('ratio:', +(Math.round((res.peers > 0 ? res.seeds / res.peers : res.seeds) +'e+2') + 'e-2'));
        }).catch(function (err) {
            console.log('error:', err);
        });
      </script>
    </body>
</html>



Solution 1:[1]

That's a Node.js library. It's not expected to be run in a browser. It internally uses the Node.js API.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jabaa