../node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <!doctype html>
| <html>
| <head>
Getting this error after I installed sqlite3 with my nextron app
After this I start getting the following error
ModuleParseError: Module parse failed: Unexpected token (9:6)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| // This script needs to be compatible with PowerShell v2 to run on Windows 2008R2 and Windows 7.
|
> using System;
| using System.Text;
| using System.Runtime.InteropServices;
After that starts getting this error import error
Error: /home/Ankit/Projects/test/node_modules/electron/dist/resources/electron.asar/package.jsondoes not exist
> 1 | const sqlite3 = require("sqlite3").verbose()
^
Don't know how to encounter this, any help would be better, thankyou in advance...
First error get resolved if I add the following code to my next.config.js file
config.module.rules.push({ test: /.html$/, use: "html-loader", });
I resolved the second error too by adding the following code to next.config.js file
config.module.rules.push({
test: /\.cs$/,
use: "raw-loader",
});
Also used electron-builder
Also used a substitute better-sqlite3 but getting error of undefined indexOf on initialization.
I'm using: node v16.20.0 sqlite3 v5.1.6 @mapbox/node-pre-gyp v1.0.10
You are trying to load a binary Node.js addon -
node-sqlite3which depends on@mapbox/node-pre-gyp. Depending on what exactly you are doing, this may be impossible.First of all, these modules do not work in the browser. In the case of Electron, they will work only in the Node.js process.
However in your particular case you also have
webpack- probably as part ofnext.js.webpacktries to make a bundle out of yournode_modulesand chokes on the code that finds and loads the shared library.You will have to manually tell
webpackto treat the shared library - usually a file ending in.node- as anexternaland to leave therequire()in your code. Look in theindex.jsofnode-sqlite3. You may have to edit it, so that the path to the.nodefile is fixed instead of being autodetected - thiswebpackcannot handle.Then, if your code is executed in the Node.js environment, it will be able to load the library. If it is loaded in the UI render process, it will fail.
I just did something very similar with
next.jsthis way:next.config.js:(I am using my own binary module that also uses
@mapbox/node-pre-gypcalledeverything-json)