nodejs app works fine when starting with node, but fails when starting from index.html in nwjs

I’m using next technologies in my app:
nodejs v7.2.1
nwjs v0.19.0
node in nwjs v7.2.0
Windows 10 Pro x64
npm ffi
npm ref
npm ref-array
npm sleep
MasterRD.dll

Code, that fails:

var CARDREADER = (function() {
    window.CARDREADER = CARDREADER;

    var ffi = require('../cardreader/node_modules/ffi'),
        ref = require('../cardreader/node_modules/ref'),
        ArrayType = require('../cardreader/node_modules/ref-array'),
        Sleep = require('../cardreader/node_modules/sleep'),
        CharArray = ArrayType(ref.types.char),
        chatPtr = ref.refType('char'),
        intPtr = ref.refType('int32'),
        BUFFER_LENGTH = 20,
        stateAvailabilityCard = false,
        statusConnected = 1;

    RFIDfunctions = ffi.Library('../cardreader/MasterRD', {
        'rf_init_com': ['int', ['int', 'int']],//Port, bound rate
        'rf_light': ['int', ['int', 'int']],//Device ID, 0 = off 1 = red 2 = green 3 = yellow
        'rf_beep': ['int', ['int', 'int']],//Device ID, beep time msec
        'rf_antenna_sta': ['int', ['int', 'int']],//Device ID, model = 0: turn off RF transmittal model = 1: turn on RF transmittal
        'rf_init_type': ['int', ['int', 'int']],//Device ID, type = 'A': set SL500 into ISO14443A modetype = 'B': set ISO14443B modetype = 'r': set AT88RF020 card modetype = '1': set ISO15693 mode
        'rf_request': ['int', ['int', 'int', chatPtr]],// Device ID, model: [IN] REQ MODE, pTagType: [OUT] response data, chip type code
        'rf_anticoll': ['int', ['int', 'int', CharArray, chatPtr]],//Device ID,  bcnt: [IN] must be 4, pSnr: [OUT] response data from card, unique serial number pLen: [OUT] length of response data
        'rf_select': ['int', ['int', CharArray, 'int', chatPtr]],//Device ID, pSnr: [IN] card unique serial number, snrLen: [IN] length of pSnr, pSize: [OUT] response data from card, capacity code
        'rf_M1_authentication2': ['int', ['int', 'int', 'int', 'pointer']],//Device ID, model: [IN] key validate mode, block: [IN] block absolute address, pKey: [IN] 6 bytes password
        'rf_M1_readval': ['int', ['int', 'int', intPtr]], //Device ID, block: [IN] block absolute address, pValue: [OUT] response value at HEX format, low byte in former
        'rf_M1_initval': ['int', ['int', 'int', 'int32']], //Device ID, block: [IN] block absolute address, pValue: [IN] initialize purse value at HEX format, low byte in former
        'rf_M1_read': ['int', ['int', 'int', CharArray, chatPtr]],//Device ID, block: [IN] block absolute address, pData: [OUT] response data from card, pLen: [OUT] length of response data
        'rf_M1_write': ['int', ['int', 'int', 'pointer']], //Device ID, block: [IN] block absolute address, pData: [IN] written data, 16 bytes
        'rf_ClosePort': ['int', []]
    });

    return {
    };
})();
Uncaught Error: A dynamic link library (DLL) initialization routine failed.
\\?\C:\Users\someUser\Desktop\dev\nwjs\projects\my-betshop\cardreader\node_modules\ref\build\Release\binding.node
    at Object.Module._extensions..node (module.js:640:18)
    at Module.load (module.js:512:32)
    at tryModuleLoad (module.js:471:12)
    at Function.Module._load (module.js:463:3)
    at Module.require (module.js:522:17)
    at require (internal/module.js:20:19)
    at bindings (C:\Users\someUser\Desktop\dev\nwjs\projects\my-betshop\cardreader\node_modules\bindings\bindings.js:76:44)
    at Object.<anonymous> (C:\Users\someUser\Desktop\dev\nwjs\projects\my-betshop\cardreader\node_modules\ref\lib\ref.js:5:47)
    at Module._compile (module.js:595:32)
    at Object.Module._extensions..js (module.js:610:10)

Author: Fantashit

1 thought on “nodejs app works fine when starting with node, but fails when starting from index.html in nwjs

  1. Solved ” Uncaught Error: Cannot find module ‘./build/Release/node_sleep.node’ “:

    rm -rf node_modules
    npm cache clean
    npm install

Comments are closed.