How to run a js file? : <p>I'm trying to get all links of the articles of one blog  ( <a href="https://www.mrmoneymustache.com" rel="nofollow noreferrer">https://www.mrmoneymustache.com</a> ) so I can compile them into a pdf, but i'm a complete noob in javascript. Somebody on reddit told me to use this code, which is supposed to do what I want :</p>

<pre><code>const fs = require('fs');
const EventEmitter = require('events').EventEmitter;
const fetch = require('node-fetch');
const cheerio = require('cheerio');

const e = new EventEmitter();

e.on('fetchPage', link =&gt; {
  fetch(link).then(r =&gt; r.text()).then(cheerio.load).then($ =&gt; {
    const nextLink = $(".next_post a").attr('href');
    if (nextLink === undefined) return; // end on final page
    const postTitle = $(".headline").text();
    const postContent = $(".post_content").html();
    console.log(postTitle);
    fs.writeFileSync(postTitle + ".html", postContent);
    setTimeout(() =&gt; e.emit('fetchPage', nextLink), 5000);
  });
});

e.emit('fetchPage', 'https://whatever/post1');
</code></pre>

<p>But I dont really get how I am supposed to run this program.. Help please ?</p>
