Node-oracledb: Error: The specified module could not be found

Created on 9 Jun 2017  路  32Comments  路  Source: oracle/node-oracledb

SYSTEMINFO:
windows10x64,node is 6.11.0, oracledb 1.13.1
"npm install " is successful.
followed all the steps of the install manual (twice checked)

START MY APP:
$ node server/server.js

ERROR:
C:\git\userdataenricher\node_modules\oracledb\lib\oracledb.js:38
throw err;
Error: Cannot find specified module
\?\C:\git\userdataenricher\node_modules\oracledb\build\Release\oracledb.node

PROBLEM ANALYSIS:
Node is looking to map .../node_modules/build/release/oracledb (first image below)
My projectmap structure is .../node_modules/build/release/obj/oracledb (second image below)
Question: how did come? Install issue? Wrong version?
Would be very pleased if anyone can help.

image

image

install & configuration

Most helpful comment

For anyone having this issue in the future:

ERROR:
C:\git\userdataenricher\node_modules\oracledb\lib\oracledb.js:38
throw err;
Error: Cannot find specified module
\?\C:\git\userdataenricher\node_modules\oracledb\build\Releaseoracledb.node

I had the same issue when using MS Visual Studio 2017.

I uninstalled MS Visual Studio 2017 (and the SDK and C++ build tools that came with it) and installed windows-build-tools instead.

That fixed the issue for me.

My system:
Win 8.1 Enterprise
node v6.9.1

All 32 comments

Thanks for checking into the paths being used.

followed all the steps of the install manual

What exact commands did you run and where? Where did you get Node from? Did you have any other versions of Node (or npm, in particular) installed? Did you have windows-build-tools? I'm just fishing here, since I don't know what might have influenced the install layout you have.

Tnx for replying!

Your question about node & npm:
Node and npm where already on my machine before i started installing node-oracledb
npm --version is 5.0.3, no other install on my machine
node --version is 6.11.0

Your question about windows-build-tools:
I used this manual: https://community.oracle.com/docs/DOC-931127
So i did install python version 2.7.3
and Visal Studio 2013 (after deinstalling 2015, i red somewhere that is was recommended with node v6 or higher, but after a lot of install problems last week i decided to dowgrade to 2013)

Suggestions/considerations
1) i did clone an existing project form a colleague, he is using a macbook, i am working on windows 10, could that explain something?
2) after installing the oracle-db stuf and cloning the project i did the command "npm install" A node-gyp rebuild was done, and oracledb installed in my project/node_modules file. Package.json:
{
"name": "userdataenricher",
"version": "0.1.0",
"description": "Userdata Enricher IDM Connect",
"main": "server/server.js",
"scripts": {
"start": "node server/server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "SDS",
"license": "UNLICENSED",
"dependencies": {
"async": "^2.1.2",
"feedparser": "^1.1.5",
"ibm_db": "^1.0.1",
"lodash": "^4.17.2",
"mysql": "^2.11.1",
"node-gyp": "^3.6.2",
"oracledb": "^1.13.1",
"request": "^2.75.0",
"striptags": "^2.1.1",
"xml2js": "^0.4.17"
}
}
3) Part of the code of the installed Oracledb.js says:
oracledbCLib = require('../build/Release/oracledb');
But installed is .../node_modules/build/release/obj/oracledb
So the oracledb module is put in the folder"obj" but the oracledb module doesn't now?
Isn't that typically an indication for another version?

3) Part of the code of the installed Oracledb.js says:
oracledbCLib = require('../build/Debug/oracledb');
But installed is no folder "Debug"
Also version indication?

Hope this helps.
Looking forward to your answers/suggestions.

Node 6 came with npm 3 - at least on Linux. You have npm 5. Your problem rang a bell about a previously reported solution identifying that there were multiple npm installed and the wrong was being used. I can't find the reference at the moment, and can't remember the actual situation. Your package.json also specifies a (newer?) node-gyp version, which may not may not be good.

Personally I'd start with a fresh Node.js and no package.json, and get a vanilla install working.

You could try debugging node-gyp. I see it does reference a /obj directory, however the doc says

Now you have your compiled .node bindings file! The compiled bindings end up in build/Debug/ or build/Release/

The answer to your fourth question is that the Debug directory will be built if the install is passed a --debug flag. The oraceldb.js file will look for Debug first and then look for the Release directory. We use this during development.

Are you sure your build completed

@cjbj As I commented here when I thought it was only happening in Node 8 I too am getting this error no matter my Node version on Windows Server 2012R2. I cannot test desktop versions of Windows currently but my results are nearly identical now that I am trying to get it to work on Node 6.11.0 and NPM 3.10.10.

Any help with solving what's going on would be great as I'm running out of ideas and time :(

To note on the server I'm building on I have VS2017 installed and I installed windows-build-tools from NPM as well. I've tried building from the VS command line and Powershell to the same outcome on both Node 8.X and 6.X at this point. I know I had a working version on Node 6 and 7 before now so it's really frustrating now that we are about to release and it doesn't work.

Another thing to note is I've tried using each valid version back to 1.11.0 and they each fail the same way. Build succeeds with no error, but then runtime can't find oracledb.node even though it is clearly there in the folder it's looking in.

This was tested on Node 8 and Node 6.

@cjbj My best guess is maybe in this line:

Error: The specified module could not be found. \\?\C:\Users\Administrator\Downloads\dist\dist\node_modules\oracledb\build\Release\oracledb.node

I see there is \\?\C..., maybe there's something in the package that is creating a bad directory path? But even then I don't understand what would be causing that since I went back 3 versions and get the same thing. Is this a Node issue?

@firrae What happens if you change line 35 in oracledb/lib/oracledb.js from this:

  oracledbCLib =  require('../build/Release/oracledb');

to this:

  oracledbCLib =  require(__dirname + '/build/Release/oracledb');

Also, what happens if you run the following single line Node.js app (run from a file):

var test = require('../moduleThatDoesntExist.js');

@dmcghan Changing that line in my little test file in Node 6.11 produces the following:

C:\Users\Administrator\Downloads\oracleTest\node_modules\oracledb\lib\oracledb.js:46
        throw new Error(nodbUtil.getErrorMessage('NJS-045'));
        ^

Error: NJS-045: cannot load the oracledb add-on binary
    at Object.<anonymous> (C:\Users\Administrator\Downloads\oracleTest\node_modules\oracledb\lib\oracledb.js:46:15)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Administrator\Downloads\oracleTest\node_modules\oracledb\index.js:1:80)
    at Module._compile (module.js:570:32)

To answer your second question:

var oracledb = require('oracledbx');

console.log(oracledb);

Produces:

PS C:\Users\Administrator\Downloads\oracleTest> node .\index.js
module.js:471
    throw err;
    ^

Error: Cannot find module 'oracledbx'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Administrator\Downloads\oracleTest\index.js:1:78)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

@dmcghan more specifically to copy your single line directly:

PS C:\Users\Administrator\Downloads\oracleTest> node .\index.js
module.js:471
    throw err;
    ^

Error: Cannot find module '../moduleThatDoesntExist.js'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Administrator\Downloads\oracleTest\index.js:5:12)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

@dmcghan to note there is no Debug folder in my built version hence it seems line 41 is also failing, potentially indicating the modules are found but there's something else wrong with them?

@firrae ah. you posted here too. This can be confusing for the original poster, since the causes may be different.

Check you have the Oracle client (e.g. Instant Client) in your path. Try changing oracledb/lib/oracledb.js so it looks for the actual path your oracledb.node binary. Try and work out what is installing differently from when things used to work. Based solely on the detective work of one person (I keep forgetting the issue #), see if you are using the 'right' npm for your node installation.

@cjbj I can create a new issue if you'd like but the title is exactly the one I was going to create lol.

As for the second part of changing the path to be exact, when I do that I get the Error: NJS-045: cannot load the oracledb add-on binary error I posted above (the same as using __dirname) which looking at the code tells me that something has compiled incorrectly as it's tried to load the Release one, hit an error that's not "Not Found" and then failed to find the Debug driver as I didn't install in debug mode, then errors to that.

As for looking back, I cannot. My company recently went through and refreshed all our dev environments that hadn't been touched in 2 months. The oldest working version I have of node-oracle working on a Windows server is on WS2016, which is different under the hood than 2012R2 I think so I can't just move the built lib? It still works, the files look the same, so at that point, I have no clue where the issue could lie other than the compiled code.

As for the right NPM, I'd hope it is as I am raw installing Node from the official MSI and using the NPM that comes with it.

@cjbj is this potentially an issue with having VS2017 installed on the server? That is the only thing I can think of that makes the environment I was running under different than my current one. That being said I still installed windows-build-tools and used Powershell rather than the VS2017 command line.

To follow up on what I've said. I tested out WS2016 server and it's working fine. I checked moving the oracledb folder from the working WS2016 to the not working WS2012R2 and got the original issue of Error: The specified module could not be found. So I have no idea what is wrong. Looking at the oracledb.js in the lib folder they are identical.

@firrae The install guide lists the VS redistributables required for each the Oracle client library versions. (The list is updated for 12.2 in the https://github.com/oracle/node-oracledb/blob/dev-2.0/INSTALL.md#instwin). Also check PATH is correct, and you have the 32 or 64 bit Oracle client libraries, matching the architecture of your Node.

@cjbj I have the Oracle Instant Client 12.1 installed the same way I did on the working WS2016 box. I also have VS2017 installed and I installed the windows-build-tools from NPM. PATHs and environment variables are set for everything as needed as shown in the install guide. I can reconfirm that when I get into work again tomorrow, but I'm 99.9% sure it all correct and since there are no build errors on install I can't think how this is a possible cause?

I remember only needing to install windows-build-tools + instant client to get all the stuff required to build on Windows before, so I figured having VS2017 wouldn't hurt as it's required for something else I was playing with, I wouldn't need 2 boxes then.

Also to note everything is 64 bit, I double checked that.

Also, is there a piece of documentation on what Windows versions are cross-compatible with native modules (I think Windows 10 and WS2016 have compatible binaries)? Like if I built this on WS2017 and it works should the same node-oracledb build work on 2012R2? I tried this today and it didn't work. I also tried the build from the 2012R2 server on the 2016 server to the same "Module not found" error.

Check you have the right redistributable tomorrow. I can't tell you which one you need - I don't know your Oracle client version (when you log a new issue, the template asks for version info...)

@cjbj OK, so I've checked the redists we have installed and on Windows Server 2012 R2 x64 we have 2013 x64, and 2015 x64. I had to remove the 2017 x64 to get the 2015 to install, but under both it still produces the same outcome.

screen shot 2017-06-28 at 14 29 52

Oracle instant client is version 12.1.0.2.0 x64 (basic + sdk) (we've decided to lock to that versoin for now, and it is working on WS2016).

Modifying line 35 of the oracledb.js in lib to require('C:\Users\Administrator\Downloads\oracleTest\node_modules\oracledb\build\Release\oracledb.node') produces: Error: NJS-045: cannot load the oracledb add-on binary.

If you want me to make a new issue, just say.

You have Oracle Client 12.1 with the 2013 redistributable?

From the node-oracledb Windows install prerequisites

Oracle client 12.1 requires the Visual Studio 2010 redistributable.

Sorry not to be more helpful: I haven't used Windows for a long time. But I did do some rewriting this morning of the Windows Install doc to try and make the redistributable requirements clearer. I'll push the doc later.

I'd be curious to know what error you see running node-oracledb 2.0.13 (before you change the redistributables). It can be installed with:

npm install oracle/node-oracledb.git#dev-2.0

I'd recommend using the 12.2 client, if only for the pool ping improvements.

@cjbj nah, that's cool, I must have missed it somewhere in the pipe. I dislike Windows and usually use Linux or Mac but sadly clients still use Windows lol. I did plan on trying 2.0, but it will have to be tomorrow as we've had a couple other things come up today that's backlogged me.

I did expect the build would fail if the redist wasn't correct, but maybe there's something I don't know about how native modules work.

I will look at 12.2, it's just I know 12.1 works with the majority of our clients so I'll double check that nothing funky will happen first.

Thanks

@cjbj So I've been banging my head against this now for a couple of days trying to get 2.0 to build but I continue getting the same issue Error: The specified module could not be found.. Is this an issue with using VS 2017? Alternatively, is VS even required or can I use Windows build tools to compile this fine? I think the core of all my issues right now lies with VS, but I can't tell for sure. I'm going to have our IT guys wipe and replace my Windows Server 2012R2 with a fresh instance so I can try starting from scratch again.

VS is not required. You can use Windows build tools to compile -- I've done it anyway! I suspect a missing dependency is the source of your troubles. I have installed VS 2017 on my virtual machine to see if I can replicate this issue myself. If I find anything I'll update this further. You could look at the dependencies using Dependency Walker (http://www.dependencywalker.com/) and see if anything turns up there. You can also check to make sure that your Node installation is 32-bit or 64-bit (process.arch) and that the version you are compiling is the same! You can use dumpbin to verify that. Hopefully some of this is helpful!

@firrae sorry you're having so much pain. Other than Anthony's advice, check you do have the right Oracle client libs in your PATH - and that PATH is set correctly. I have read that sometimes what you think is set is not what is actually used, depending on the admin privs used.

@firrae FWIW, I just pushed an updated INSTALL.md with a Troubleshooting section derived from the previous Issue logging template.

@cjbj this isn't directly your fault and I hope you don't take this personally at all, it's just frustrating having to support an OS that is so badly prepared to support basic concepts...

I have 0 issues on MacOS and Linux (4 variants of Linux actually), but the Windows (Server) world is a mess...

OK, so going through on a fresh Windows Server 2012 R2 instance I did the following exactly as I write it:

1) Installed Node version 8.1.3
2) Installed windows-build-tools in an Admin level powershell
3) Installed the instant client 12.2 (Basic) into C:\oracle\instantclient_12_2
4) Put that into the PATH using the method outlined in the install guide
5) Installed the 2013 Redist from the link on the install guide that led me to the following download: https://support.microsoft.com/en-us/help/3179560/update-for-visual-c-2013-and-visual-c-redistributable-package
6) Added C:\Windows\SysWOW64 to the PATH as that is where the redist installs to
6.1) PATH now is the following: C:\Users\Administrator\.windows-build-tools\python27\;C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\Administrator\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\.bin;C:\Users\Administrator\AppData\Roaming\npm\node_modules\.bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\nodejs\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Users\Administrator\AppData\Roaming\npm;C:\oracle\instantclient_12_2;C:\Windows\SysWOW64
7) Ran npm i oracledb in a new Powershell to make sure it has the updated PATH
8) Ran my little test file that is just:

var oracle = require("oracledb");
console.log(oracle);

It seems to work. Now I will test packaging it up into a distributable exe via nodec and add in some other testing to make sure 2.0 works as the previous version did.

Thank you, all @cjbj, @anthony-tuininga, and @dmcghan, I have no clue what the issue was, but it seems to be working now.

Is there a date when you expect 2.0 to hit NPM? I don't mind sending out beta code right now as the group who wants it is just in a trial phase right now, but an "official release" version always is better sounding to a customer. ;p

Also, I notice that in the install guide you say to run npm install oracledb before you talk about installing the instant client but I think it's required to be there before you do so?

Thank you, all @cjbj, @anthony-tuininga, and @dmcghan, I have no clue what the issue was, but it seems to be working now.

Glad you got things working. I'll let @cjbj comment on the timeline for an official 2.0 release but it is intended to be "soon" (for some definition of that word!).

Also, I notice that in the install guide you say to run npm install oracledb before you talk about installing the instant client but I think it's required to be there before you do so?

The instant client does not need to be installed prior to the building of node-oracledb 2.0. It was needed for the 1.x releases, so that may be the source of confusion.

Ah, I see @anthony-tuininga, cool to see that the SDK and even the basic instant client isn't required now to build.

@firrae I don't have a firm date for 2.0 production. We're all keen to get it out. One or two more stress test issues need some triage so we know the causes etc. The more early testing people do, the better.

I haven't seen any followup from the original poster so I'll close this now.

Sorry @git4bram if I hijacked this on you, it just seemed we were potentially having the same issue considering we were getting the same error. Hopefully, yours is resolved and if not sorry.

For anyone having this issue in the future:

ERROR:
C:\git\userdataenricher\node_modules\oracledb\lib\oracledb.js:38
throw err;
Error: Cannot find specified module
\?\C:\git\userdataenricher\node_modules\oracledb\build\Releaseoracledb.node

I had the same issue when using MS Visual Studio 2017.

I uninstalled MS Visual Studio 2017 (and the SDK and C++ build tools that came with it) and installed windows-build-tools instead.

That fixed the issue for me.

My system:
Win 8.1 Enterprise
node v6.9.1

Was this page helpful?
0 / 5 - 0 ratings