question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
AlexKotovcommented, Dec 9, 2016

Solved " Uncaught Error: Cannot find module ‘./build/Release/node_sleep.node’ ":

rm -rf node_modules npm cache clean npm install

0reactions
findingneo17commented, Sep 13, 2018

/root/.npm/_logs/2018-09-13T08_56_41_795Z-debug.log: 2411 silly install sleep@4.0.0 2412 info lifecycle sleep@4.0.0~install: sleep@4.0.0 2413 verbose lifecycle sleep@4.0.0~install: unsafe-perm in lifecycle true 2414 verbose lifecycle sleep@4.0.0~install: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/volume1/git/node-ffmpeg-mpegts-proxy/node_modules/sleep/node_modules/.bin:/volume1/git/node-ffmpeg-mpegts-proxy/node_modules/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin:/var/services/homes/Enoch/bin:.:/root/bin:. 2415 verbose lifecycle sleep@4.0.0~install: CWD: /volume1/git/node-ffmpeg-mpegts-proxy/node_modules/sleep 2416 silly lifecycle sleep@4.0.0~install: Args: [ ‘-c’, ‘node-gyp rebuild’ ] 2417 silly lifecycle sleep@4.0.0~install: Returned: code: 1 signal: null 2418 info lifecycle sleep@4.0.0~install: Failed to exec install script 2419 verbose unlock done using /root/.npm/_locks/staging-88f7d7341732df16.lock for /volume1/git/node-ffmpeg-mpegts-proxy/node_modules/.staging 2420 silly saveTree node-ffmpeg-mpegts-proxy@0.8.0 2420 silly saveTree ├─┬ chokidar@1.7.0 … 2420 silly saveTree ├── sleep@4.0.0 2420 silly saveTree ├─┬ winston@0.8.3 2420 silly saveTree │ ├── async@0.2.10 2420 silly saveTree │ ├── colors@0.6.2 2420 silly saveTree │ ├── cycle@1.0.3 2420 silly saveTree │ ├── eyes@0.1.8 2420 silly saveTree │ ├── isstream@0.1.2 2420 silly saveTree │ ├── pkginfo@0.3.1 2420 silly saveTree │ └── stack-trace@0.0.10 2420 silly saveTree └── yargs@1.3.3 2421 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents): 2422 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”}) 2423 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin 2423 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any 2423 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: linux 2423 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64 2424 verbose stack Error: sleep@4.0.0 install: node-gyp rebuild 2424 verbose stack Exit status 1 2424 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16) 2424 verbose stack at emitTwo (events.js:126:13) 2424 verbose stack at EventEmitter.emit (events.js:214:7) 2424 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 2424 verbose stack at emitTwo (events.js:126:13) 2424 verbose stack at ChildProcess.emit (events.js:214:7) 2424 verbose stack at maybeClose (internal/child_process.js:925:16) 2424 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) 2425 verbose pkgid sleep@4.0.0 2426 verbose cwd /volume1/git/node-ffmpeg-mpegts-proxy 2427 verbose Linux 4.4.59+ 2428 verbose argv “/volume1/@appstore/Node.js_v8/usr/local/bin/node” “/usr/local/bin/npm” “install” “–unsafe-perm” 2429 verbose node v8.9.4 2430 verbose npm v5.6.0 2431 error code ELIFECYCLE 2432 error errno 1 2433 error sleep@4.0.0 install: node-gyp rebuild 2433 error Exit status 1 2434 error Failed at the sleep@4.0.0 install script. 2434 error This is probably not a problem with npm. There is likely additional logging output above. 2435 verbose exit [ 1, true ]

Read more comments on GitHub >

github_iconTop Results From Across the Web

start script not working with npm start, but works fine with node ...
Some middleware issue that only applies with start script. I am using app.use("/client", express.static("client")); , within my server.js ...
Read more >
nwjs/nw.js - Gitter
Hey, im trying to run a react with with nw js as well as a background script. ... show a dock icon in...
Read more >
JavaScript Contexts in NW.js
When a script accessing to an object / function defined in another context, JS engine will temporarily enter the target context and leave...
Read more >
Writing and running your first "Hello World" app | NW.js ...
If you try to open index.html in a browser, you'd get the Reference Error: require is not defined error as Node.js has not...
Read more >
Chapter 1. Introducing Electron and NW.js - Cross-Platform ...
Understanding why Node.js desktop apps are the rage these days; Previewing Node.js desktop ... You don't require internet access to start and run...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found