Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Issues with node.js and JS. Require not defined and more

Featured Replies

I'm having a few issues with a plugin I am writing. This is my first foray into node.js and JS. I have a rudimentary webui that displays a database as a table. I use PHPStorm as my IDE and it works fine in there but when I just try to get it to display in unraid it keeps saying it is not a database file. It is a sqlite file, database.db. I think it's an environmental issue in unraid. I'm not sure where exactly I need to put the file but I've tried several different locations. Maybe I am missing a module or something. This is the first bit that it gets caught up on.

 

async function loadData(count) {
  const sqlPromise = initSqlJs({
    locateFile: file => `${file}`
  });
  const dataPromise = fetch("database.db").then(res => res.arrayBuffer());
  console.log(dataPromise);
  const [SQL, buf] = await Promise.all([sqlPromise, dataPromise])
  const db = new SQL.Database(new Uint8Array(buf));



The second issue is I keep getting an error about require not being defined. I first got it when trying to use a module to read sql files. I thought that was simple enough to fix, just needed to make sure require was installed. I was never able to fix it but instead used some other example that didn't use it (same as above). However, I am getting the issue again when trying to use FS module to write a file. I'm not sure why it keeps saying require is not defined when it is installed.

 

function list() {
  // include node fs module
  var fs = require('fs');

// writeFile function with filename, content and callback function
  fs.writeFile('files.txt', tester(), function (err) {
    if (err) throw err;
    console.log('File is created successfully.');
  });
}

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.