简体   繁体   中英

NWJS - A dynamic link library (DLL) initialization routine failed

I'm tryin to build an app which requires sqlite3 Modul. My app works fine when I run it from cmd node server.js but when I run it from NWJS crashes and throws the error below

Uncaught Error: A dynamic link library (DLL) initialization routine failed.
\\?\C:\Users\Coder Bilall\Desktop\My Work\NWJS\GMoney\Gmoney\node_modules\sqlite3\lib\binding\napi-v3-win32-x64\node_sqlite3.node
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1206:18)
    at Module.load (node:internal/modules/cjs/loader:991:32)
    at Function.Module._load (node:internal/modules/cjs/loader:831:14)
    at Module.require (node:internal/modules/cjs/loader:1015:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (C:\Users\Coder Bilall\Desktop\My Work\NWJS\GMoney\Gmoney\node_modules\sqlite3\lib\sqlite3-binding.js:4:15)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1161:10)
    at Module.load (node:internal/modules/cjs/loader:991:32)
    at Function.Module._load (node:internal/modules/cjs/loader:831:14)

My server.js Code

const express = require('express')
const sqlite3 = require('sqlite3').verbose();
const LocalStorage = require('node-localstorage').LocalStorage;
let exec = require('child_process').exec, child;
const connectionTester = require('connection-tester');
const notifier = require('node-notifier');
const path = require('path');
const fs = require('fs');
const os = require('os');
const readline = require('readline');
const {google} = require('googleapis');
const ToCsv  =  require("sqlite-to-csv");
var cookieParser = require('cookie-parser')
const mailjet = require ('node-mailjet')
.connect('878dcf9b5a0ae7cf07498b6ab3d73ca7', 'c6c90ff0878e2b9640a6c342f84e142e')


const db = new sqlite3.Database('mydb.db');
const application = express();
application.use(cookieParser());
const port = 2020;

 application.get('/', (req, res) => {
        
     res.send('Hello World');


    });


 application.listen(port, () => {
     console.log(`Example application listening at http://localhost:${port}`)
 })

Please Help me

The code failing is referencing a node binding sqlite3\lib\binding\napi-v3-win32-x64 .

When you npm install some node modules will download or build files unique to your operating system ( win32 , linux , darwin ), your architecture ( x86 , x64 ), and your Node.js ABI Version ( 47 , 72 , 88 ). If your globally installed version of Node is not the same as the version built in to NW.js, your module will be incompatible.

Try this:

  1. Delete your node_modules and package-lock.json
  2. Change your Node.js version to be the same as what is built in to that version of NW.js
  3. Then do an npm install and see if it works

This may not be your issue, but it may resolve other issues and is quick to test.

What version of Node.js is in NW.js?

How do I switch Node.js versions globally?

You may also want to look at this NW.js wiki page:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM