electron: Unable to use native module vscode-nsfw with Electron 4.0.0-beta.5
- Output of
node_modules/.bin/electron --version: 4.0.5-beta.5 - Operating System (Platform and Version): Windows 10
- Output of
node_modules/.bin/electron --versionon last known working Electron version (if applicable): 3.0.6
Expected Behavior A native module works when compiled against Electron.
Actual behavior
A native module vscode-nsfw when required throws the following error:
Error: The specified module could not be found.
\\?\C:\Users\bpasero\Desktop\vscode-nsfw\node_modules\vscode-nsfw\build\Release\nsfw.node
To Reproduce
- setup a
.yarnrcfile with belows contents
disturl "https://atom.io/download/electron"
target "4.0.0-beta.5"
runtime "electron"
- add a dependency to
package.json:"vscode-nsfw": "*" - run
yarn - require
vscode-nsfwin the electron app - get the error
When I follow the same steps by compiling this module against a globally installed node.js 10.11.0 (the same as Electron 4.0.0-beta.5) I can successfully load the module. As such I assume that it is not the modules fault here.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 23 (22 by maintainers)
I was able to solve this problem by removing the following line from
binding.gyp:win_delay_load_hook: falseThe “module not found” issue was unrelated and only appeared because I depended on a GitHub branch directly via
package.jsoninstead of publishing a new version with this change (which is needed to trigger some file operations that are required as part of theprepublishstep).Sorry for the confusion and thanks for the help!
Yes, this changed in 4.0.0 because in 4.0.0 we build as a single static executable, not as
electron.exe+node.dll. Previously, native modules were linked againstnode.dll, but that dll no longer exists. So we have to do some trickery to make native modules work.Unfortunately the build output you pasted does not show the link command, so I can’t tell if it’s correctly linking with
/DELAYLOAD:node.lib. Can you add more--verboseflags (possibly to the node-gyp invocation itself) and try again?I don’t think
RUN_AS_NODEshould make a difference here.@bpasero Can you try renaming
electron.exetonode.exeand see if it loads?