Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"The specified module could not be found." although module does exist #2

Open
jonnysmith1981 opened this issue May 9, 2017 · 27 comments
Assignees

Comments

@jonnysmith1981
Copy link

I have succesfully downloaded and built the win32 x64 version of this module for Electron 1.6.1. However when i run the electron app, i get the following error:

The specified module could not be found: electron\app\node_modules\win-sqlcipher\node_modules\sqlite3\lib\binding\electron-v1.6-win32-x64\node_sqlite3.node

However I have confirmed that the module does actually exist in that path.

@lihang1870719
Copy link

I also count this problem

@fritx fritx self-assigned this May 10, 2017
@silaspedrosa
Copy link

Same thing here. How did you rebuild the module? Was it by simply using electron-rebuild?

@fritx
Copy link
Owner

fritx commented Jun 17, 2017

I've reproduced it in the nwtest.

@davidbnk
Copy link

@fritx I'm experiencing this problem in Electron as well. Is this something you are working on?

fritx added a commit to fritx/unix-sqlcipher that referenced this issue Jun 18, 2017
@fritx
Copy link
Owner

fritx commented Jun 18, 2017

Yes, I'm trying to add an electron test to win-sqlcipher as well.

unix-sqlcipher seems to have no problem with this,
just installing cross-sqlcipher and then electron-rebuild (with electron v1.6.10):
fritx/unix-sqlcipher@f9670a8#diff-8403e4058fa0aef6b1fae216ff3c8c9c.

Sorry about the trouble, it would take a few days to look into the win problem.

@silaspedrosa
Copy link

@fritx cool! Looking forward to it! This repository looks like a dream! It's been so hard to use sqlcipher with electron on Windows and win-sqlcipher just looks THE plug n' play solution!

@lihang1870719
Copy link

I solve this problem by rebuilding sqlite3 with electron and openssl. other things to remind, you may need to build sqlcipher with the static lib, otherwise your app can not run in other's computer

@fritx
Copy link
Owner

fritx commented Jun 19, 2017

@lihang1870719 👍 nice, could you share more details?
ref: #1, fritx/cross-sqlcipher#2

What versions of node/npm/node-gyp/node-pre-gyp stuffs did you use, @ALL?

Btw, cross/win/unix-sqlcipher was built against node4/npm2, which is so old,
see https://github.com/fritx/win-sqlcipher/blob/dev/postinstall.js#L23
I'm gonna to bump a minor version for npm3+ structure once I have time.

@fritx
Copy link
Owner

fritx commented Jun 19, 2017

image

Good news!
I've successfully run cross-sqlcipher in Windows with electron.

Details:

Btw, I'll add some automated CI for multiple versions of windows/node/npm/electron.
Even to cache built target and upload to the web like node-pre-gyp.

@fritx
Copy link
Owner

fritx commented Jun 19, 2017

Solved it after replacing OpenSSL.
-- fritx/cross-sqlcipher#2 (comment)

I solve this problem by rebuilding sqlite3 with electron and openssl. other things to remind, you may need to build sqlcipher with the static lib, otherwise your app can not run in other's computer
-- #2 (comment)

libeay32.dll ssleay32.dll (win32/win64) included in sources or ensure env.PATH
-- #1 (comment)

Maybe one more thing to be done, about the openssl, any idea? @liubiggun

@mo-js
Copy link

mo-js commented Jun 24, 2017

up vote for electron!
please provide a short manual for using with electron

@1inus
Copy link

1inus commented Aug 30, 2017

i have succesfully build for nwjs and electron(without any error). However when i run the app, i get the following error:
Uncaught Error: The specified module could not be found. \\?\E:\nwjs\0.13.0-ia32\node_modules\win-sqlcipher\node_modules\sqlite3\lib\binding\node-webkit-v0.13.0-win32-ia32\node_sqlite3.node

I've almost tried all of the development environments :
os - win7 ia32, win xpwin10 ia32win10 x64
node - node5.x, node6.x, node7.xnode8.x
electron - 1.6~1.7
nwjs - 0.11.0 ~ 0.14.5

I even tried to modify the source code.

It takes a lot of time to solve the problem. but in the end i failed.

Is there anyone who can help?

@fritx
Copy link
Owner

fritx commented Aug 31, 2017

@liubiggun do you still remember what we had done to the Windows7 PC?
It must had something to do with the openssl directory.

@fritx
Copy link
Owner

fritx commented Aug 31, 2017

@1inus before @liubiggun replies.
Don't know does this help:
https://github.com/liubiggun/node-sqlite3/blob/master/SQLCIPHERHOWTO.md

@1inus
Copy link

1inus commented Aug 31, 2017

@fritx the same error, an annoying thing

@1inus
Copy link

1inus commented Aug 31, 2017

I think the mistake was caused by openssl static lib

@lihang1870719
Copy link

lihang1870719 commented Sep 1, 2017

@fritx
os: mac
electron: 1.6.6
if you use sqlcipher just in your compute, you can rebuild with node-gyp, otherwise, I advise you do like this:
1、change the bind_gyp with static lib of libsqlcipher.a


     "conditions": [
        ["sqlite != 'internal'", {
            "include_dirs": [ "/usr/local/opt/sqlcipher/include/sqlcipher" ],
            "libraries": [
               "/usr/local/opt/sqlcipher/lib/libsqlcipher.a"
            ],
            "conditions": [ [ "OS=='linux'", {"libraries+":["-Wl,-rpath=<@(sqlite)/lib/libsqlcipher.a"]} ] ],
            "conditions": [ [ "OS!='win'", {"libraries+":["/usr/local/opt/sqlcipher/lib/libsqlcipher.a"]} ] ],
            'msvs_settings': {
              'VCLinkerTool': {
                'AdditionalLibraryDirectories': [
                  '<(sqlite)/lib'
                ],
              },
            }
        },

2、config the LDFLAGS
export LDFLAGS="-lcrypto"
3、rebuild
node-gyp rebuild --sqlite_libname=sqlcipher --sqlite=/usr/ --target=1.6.6 --arch=x64 --target_platform=darwin --dist-url=https://atom.io/download/atom-shell --module_name=node_sqlite3 --module_path=../lib/binding/electron-v1.6-darwin-x64

if your platform is win, I can give you more detail, thanks

@1inus
Copy link

1inus commented Sep 4, 2017

@lihang1870719 can you provide some details for windows platform?

@silaspedrosa
Copy link

If run dependency walker on the node binary generated by electron-rebuild, it'll tell you that there are a LOT of dll's missing. Maybe it has something to do with Visual Studio?

@alangrainger
Copy link

Is this the issue?

In postinstall.js, you have cd('node_modules/sqlite3') (line 23). Because execution is currently in <app_root_path>\node_modules\win-sqlcipher, the directory is not found and the below error appears:

> win-sqlcipher@0.0.4 postinstall <app_root_path_is_here>\node_modules\win-sqlcipher
> node postinstall

cd: no such file or directory: node_modules/sqlite3

From this point on, everything happens under that directory:

win-sqlcipher@0.0.4 preinstall <app_root_path_is_here>\node_modules\win-sqlcipher
node preinstall

sqlite3@3.1.4 preinstall <app_root_path_is_here>\node_modules\win-sqlcipher\node_modules.staging\sqlite3-e65909b0

npm install node-pre-gyp

sqlite3@3.1.4 install <app_root_path_is_here>\node_modules\win-sqlcipher\node_modules\sqlite3
node-pre-gyp install --fallback-to-build

Eventually you end up with a whole directory structure underneath the win-sqlcipher module folder.

I tried to make a clone of your module to test, but my NPM knowledge isn't good enough and I couldn't get it to use my local copy. However this should be super easy to test.

@fritx
Copy link
Owner

fritx commented Oct 16, 2017

@alangrainger thanks for your point.

It should work with the code, we tested it well. The strategy you mentioned was intended:
we forced win-sqlcipher to install sqlite3 in its own node_modules, so it could have full control of it.

It is probably due to, I thought, the sqlite3 version defined in package.json was a bit special,
so it could make sure sqlite3 be installed in its own node_modules.
https://github.com/fritx/win-sqlcipher/blob/dev/package.json#L22

However, I'm not pretty sure now. And you are right! Probably we should move sqlite3
from dependencies to peerDependencies or ...?

@alangrainger
Copy link

I have been testing all morning on multiple different configurations.

On a fresh Electron boilerplate, with these exact versions, I could not replicate your success:

  • Windows 10
  • node: 7.9.0
  • npm: 4.2.0
  • windows-build-tools: 1.3.2
  • electron: 1.7.0
  • electron-rebuild: 1.5.11
  • win-sqlcipher: 0.0.4

Note that I used 0.0.4 as there is no build target for 0.0.2.

There are no errors during the build process, only the module could not be found error as in the original post when trying to launch the app. This is after running electron-rebuild.

When I use just the Sqlite3 module (no win-cipher), the electron-rebuild process does successfully correct that error.

I'm wondering if it's possible to use the DLL file from this project to compile Sqlite3 against? https://github.com/sqlitebrowser/sqlitebrowser/releases

I have started to attempt it, but I'm not yet sure how to tell npm to use the DLL file. The command will be something like this:

npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite="DLL FILE HERE" --runtime=electron --target=1.7.6 --dist-url=https://atom.io/download/electron

@fritx
Copy link
Owner

fritx commented Oct 16, 2017

@alangrainger thanks! I'll look into it soon.

Btw, I recently find that electron-rebuild should be told the exact module name like:
(a bit annoying)

electron-rebuild -m node_modules/win-sqlcipher/node_modules/sqlite3
#or
electron-rebuild -m node_modules/cross-sqlcipher/node_modules/win-sqlcipher/node_modules/sqlite3

@fritx fritx added the bug label Oct 16, 2017
@alangrainger
Copy link

alangrainger commented Oct 16, 2017

I had such high hopes! Rebuild works:

PS C:\Apps\test> .\node_modules\.bin\electron-rebuild -m node_modules/win-sqlcipher/node_modules/sqlite3
√ Rebuild Complete

But then run the app, and same issue:

Uncaught Error: The specified module could not be found.
\?\C:\Apps\test\node_modules\win-sqlcipher\node_modules\sqlite3\lib\binding\electron-v1.7-win32-x64\node_sqlite3.node

Are you personally still able to get a successfully working install on a new boilerplate?

@sai-kyaw
Copy link

sai-kyaw commented Oct 17, 2017

@alangrainger - check your builds (node_sqlite3.node) for both node and electron with http://dependencywalker.com/, you should only see NODE.DLL is not found (icon - question mark inside yellow circle). If LIBEAY32.DLL is also marked as not found (most likely in electron build), you should copy SSL related dlls (libeay32.dll and libssl32.dll) to system32 folder then build again. It should resolve the issue. If not install VS2013. HTH.

P.S. you can ignore some of the missing dlls for windows.

@alangrainger
Copy link

alangrainger commented Oct 18, 2017

Holy shit it worked!!

I got the DLL files from DB Browser for SQLite Windows build, and copied them to System32, and it compiled just fine!

Here are the DLLs for anyone else who needs them: https://drive.google.com/file/d/0BwEyNB4Ss8kjLWVDVHFCVkRLT2s/view?usp=sharing

Environment:

  • Windows 10
  • Node 8.7.0
  • NPM 5.3.0 (this is important, you will get an error on a newer version. You can use npm-windows-upgrade to easily switch this)
  • windows-build-tools 1.3.2 (NPM link)
  • electron 1.7.9
  • win-sqlcipher 0.0.4

Steps:

  1. Copy DLLs to System32
  2. Install Windows Build Tools if you don't have them - npm install -g windows-build-tools
  3. npm install
  4. .\node_modules\.bin\electrion-rebuild

Note: I got this error while installing even though I have the package specified in my packages.json:

npm ERR! missing: nan@~2.3.3, required by sqlite3@3.1.4

It did not however prevent the successful compilation and running of my app. Likely something needs to be fixed, but I'm not sure what.

@rkistner
Copy link

The error "The specified module could not be found" typically means that a dll file is missing, but unfortunately the error doesn't tell you which one. The Windows Process Monitor tool is useful to find which one is missing: Just filter for the electron.exe process, and see which DLL it's looking for when you require the module, as well as the paths it's looking in. It will most likely tell you it's libeay32.dll, as others have noted here. FWIW, the best place to get a copy of the DLLs is here: https://slproweb.com/products/Win32OpenSSL.html (the 1.0.2 builds).

I've created another fork that bundles that DLL with the module: https://github.com/journeyapps/node-sqlcipher
My biggest current problem with this approach is that it prevents electron-builder from placing the module inside the asar file. However, this can be worked around by excluding the file, and copying it with the extraFiles config setting for electron-builder - something like #3 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants