bobbintb Posted December 10, 2021 Share Posted December 10, 2021 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.'); }); } Quote Link to comment
Recommended Posts
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.