<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Error Node_helper custome Module]]></title><description><![CDATA[<p dir="auto">Hey Guys i’m trying to set up a custome Module to screen the menu of my scools canteen. I ask ChatGPT for the Scripts but he can’t help me anymore thats the reason why i write here.</p>
<p dir="auto">The module is called MenuZFV and has a .js file as well as .css and also a node_helper.js which I paste below. The problem is the data can be accessed from the website: (‘<a href="https://app.food2050.ch/de/stfw/restaurant" target="_blank" rel="noopener noreferrer nofollow ugc">https://app.food2050.ch/de/stfw/restaurant</a> -stfw/menu/mittagsmenue/weekly?week=26’) cannot be accessed. Npm install in the folder was done. ChatGPT recommended puppeteer to me because there is no DOM on the website, I installed it via npm install, but when I run node node_helper.js this log comes up - can anyone help me?</p>
<p dir="auto">LOG:</p>
<pre><code class="language-text">node:internal/modules/cjs/loader:1051
  throw err;
  ^

Error: Cannot find module 'node_helper'
Require stack:
- /home/pi/MagicMirror/modules/MMM-MenuZFV/node_helper.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
    at Module._load (node:internal/modules/cjs/loader:901:27)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.&lt;anonymous&gt; (/home/pi/MagicMirror/modules/MMM-MenuZFV/node_helper.js:1:20)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/home/pi/MagicMirror/modules/MMM-MenuZFV/node_helper.js' ]
}
</code></pre>
<p dir="auto">Node.js v20.8.0</p>
<p dir="auto">.JS:</p>
<pre><code class="language-js">const puppeteer = require('puppeteer');

(async () =&gt; {
  const browser = await puppeteer.launch({ headless: true });
  const page = await browser.newPage();
  const url = 'https://app.food2050.ch/de/stfw/restaurant-stfw/menu/mittagsmenue/weekly?week=26';

  try {
    await page.goto(url, { waitUntil: 'networkidle2' });

    const menuItems = await page.evaluate(() =&gt; {
      const items = [];
      document.querySelectorAll('p.sc-e418db57-3.eOyIUO').forEach(item =&gt; {
        items.push(item.textContent.trim());
      });
      return items;
    });

    console.log('Menu Items:');
    console.log(menuItems);

  } catch (error) {
    console.error('Error fetching menu:', error);
  } finally {
    await browser.close();
  }
})();
</code></pre>
<p dir="auto">.CSS:</p>
<pre><code class="language-css">.MMM-MenuZFV .day {
    font-weight: bold;
    padding-top: 10px;
}

.MMM-MenuZFV .menu-name {
    text-align: left;
}

.MMM-MenuZFV .menu-price {
    text-align: right;
}
</code></pre>
<p dir="auto">NODE_HELPER.JS:</p>
<pre><code class="language-js">const NodeHelper = require('node_helper');
const puppeteer = require('puppeteer');

module.exports = NodeHelper.create({
  start: function () {
    console.log('Starting node helper for: ' + this.name);
  },

  socketNotificationReceived: function (notification, payload) {
    if (notification === 'GET_MENU') {
      console.log('Fetching menu from URL: ' + payload.url); // Log the URL being fetched
      this.getMenu(payload.url); // Pass the URL from payload
    }
  },

  getMenu: async function (url) {
    try {
      const browser = await puppeteer.launch({ headless: true });
      const page = await browser.newPage();
      await page.goto(url, { waitUntil: 'networkidle2' });

      const menuItems = await page.evaluate(() =&gt; {
        const items = [];
        document.querySelectorAll('p.sc-e418db57-3.eOyIUO').forEach(item =&gt; {
          items.push(item.textContent.trim());
        });
        return items;
      });

      await browser.close();

      console.log('Extracted menu items:');
      console.log(menuItems);

      if (menuItems.length === 0) {
        menuItems.push('Kein Menü gefunden.');
      }

      this.sendSocketNotification('MENU_RESULT', menuItems);
    } catch (error) {
      console.error('Error fetching menu:', error);
      this.sendSocketNotification('MENU_RESULT', ['Fehler beim Abrufen des Menüs.']);
    }
  }
});
</code></pre>
<p dir="auto">Thank you very much for your time and help.</p>
]]></description><link>https://forum.magicmirror.builders/topic/18825/error-node_helper-custome-module</link><generator>RSS for Node</generator><lastBuildDate>Sat, 13 Jun 2026 00:18:57 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/18825.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 26 Jun 2024 15:55:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Error Node_helper custome Module on Thu, 27 Jun 2024 10:22:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chiiki58" aria-label="Profile: Chiiki58">@<bdi>Chiiki58</bdi></a> awesome, glad you’re making progress.</p>
]]></description><link>https://forum.magicmirror.builders/post/118512</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118512</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Thu, 27 Jun 2024 10:22:53 GMT</pubDate></item><item><title><![CDATA[Reply to Error Node_helper custome Module on Thu, 27 Jun 2024 08:47:13 GMT]]></title><description><![CDATA[<p dir="auto">It works, thank you very much for the input. I’ll probably upload it to GIT once I get the layout right. Now I’ve just unstructured all the text from the website</p>
]]></description><link>https://forum.magicmirror.builders/post/118510</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118510</guid><dc:creator><![CDATA[Chiiki58]]></dc:creator><pubDate>Thu, 27 Jun 2024 08:47:13 GMT</pubDate></item><item><title><![CDATA[Reply to Error Node_helper custome Module on Thu, 27 Jun 2024 07:32:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> Yeah of course I have everything in the right folder with the right name</p>
<p dir="auto">I also had cheerio installed, I’ll have to check it out</p>
<p dir="auto">I’ll try it with httptojson</p>
<p dir="auto">Thank you very much, Sam</p>
]]></description><link>https://forum.magicmirror.builders/post/118509</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118509</guid><dc:creator><![CDATA[Chiiki58]]></dc:creator><pubDate>Thu, 27 Jun 2024 07:32:28 GMT</pubDate></item><item><title><![CDATA[Reply to Error Node_helper custome Module on Wed, 26 Jun 2024 16:49:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chiiki58" aria-label="Profile: Chiiki58">@<bdi>Chiiki58</bdi></a> also note the required files</p>
<p dir="auto">module_name(in config.js)  = folder_name = filename.js = register inside this file<br />
all MUST MATCH exactly</p>
<p dir="auto">your .js doesn’t have the register</p>
<p dir="auto">css file name has to match the return from</p>
<p dir="auto">getStyles: function</p>
]]></description><link>https://forum.magicmirror.builders/post/118498</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118498</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Wed, 26 Jun 2024 16:49:43 GMT</pubDate></item><item><title><![CDATA[Reply to Error Node_helper custome Module on Wed, 26 Jun 2024 16:50:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chiiki58" aria-label="Profile: Chiiki58">@<bdi>Chiiki58</bdi></a> where are you building this module??  are the files located in a folder off the MagicMirror/modules   folder??</p>
<p dir="auto">we create alias entries to the includes for some things…</p>
<p dir="auto">so your files have to be in the right place…</p>
<p dir="auto">pupetteer  is really about executing a web page, clicking, scrolling</p>
<p dir="auto">you shouldn’t need that I don’t think…</p>
<p dir="auto">cheerio will let you extract parts of the page  and<br />
<a href="https://www.npmjs.com/package/cheerio" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.npmjs.com/package/cheerio</a><br />
<a href="https://www.npmjs.com/package/html-to-json-parser" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.npmjs.com/package/html-to-json-parser</a><br />
html_to_json to convert them to json</p>
<p dir="auto">also, see my sampleModule that has working node_helper.js<br />
<a href="https://github.com/sdetweil/SampleModule" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/sdetweil/SampleModule</a></p>
<p dir="auto">also, names matter… MagicMirror is case sensitive</p>
<p dir="auto">and the link to the doc for module creators<br />
<a href="https://docs.magicmirror.builders/development/introduction.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.magicmirror.builders/development/introduction.html</a></p>
]]></description><link>https://forum.magicmirror.builders/post/118497</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118497</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Wed, 26 Jun 2024 16:50:38 GMT</pubDate></item></channel></rss>