2

I am trying to install mongodb driver for Nodejs on Windows 10 and gets the below error about Python.

Is Python a pre-requsite ? And that too it expects only Python version 2.5 to 3.0. On top of Python it keeps asking for other MS Visual Studio 2008 or MS SDK / .Net installations ? Does it need all these as pre-requsite.

C:\Jay\M101JS>npm install mongodb
-
> kerberos@0.0.14 install C:\Jay\M101JS\node_modules\mongodb\node_modules\mongodb-core\node_modules\kerberos
> (node-gyp rebuild) || (exit 0)


C:\Jay\M101JS\node_modules\mongodb\node_modules\mongodb-core\node_modules\kerberos>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:116:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:71:11
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 10.0.10240
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Jay\M101JS\node_modules\mongodb\node_modules\mongodb-core\node_modules\kerberos
gyp ERR! node -v v4.0.0
gyp ERR! node-gyp -v v3.0.1
gyp ERR! not ok
mongodb@2.0.43 node_modules\mongodb
├── es6-promise@2.1.1
├── readable-stream@1.0.31 (string_decoder@0.10.31, inherits@2.0.1, isarray@0.0.1, core-util-is@1.0.1)
└── mongodb-core@1.2.12 (bson@0.4.12, kerberos@0.0.14)

Update:

I tried again after installing Python 2.7 & Visual Studio Express (Free) and now get the below error,

C:\Jay\MongoDb\M101JS>npm install mongodb
-
> kerberos@0.0.14 install C:\Jay\MongoDb\M101JS\node_modules\mongodb\node_modules\mongodb-core\node_modules\kerberos
> (node-gyp rebuild) || (exit 0)


C:\Jay\MongoDb\M101JS\node_modules\mongodb\node_modules\mongodb-core\node_modules\kerberos>if not defined npm_config_node_gyp (node "C:\Program Files\
nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(366,5): warning MSB8003: Could not find WindowsSDKDir variable from
 the registry.  TargetFrameworkVersion or PlatformToolset may be set to an invalid version number. [C:\Jay\MongoDb\M101JS\node_modules\mongodb\node_m
odules\mongodb-core\node_modules\kerberos\build\kerberos.vcxproj]
TRACKER : error TRK0005: Failed to locate: "CL.exe". The system cannot find the file specified. [C:\Jay\MongoDb\M101JS\node_modules\mongodb\node_modu
les\mongodb-core\node_modules\kerberos\build\kerberos.vcxproj]


gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:270:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebui
ld"
gyp ERR! cwd C:\Jay\MongoDb\M101JS\node_modules\mongodb\node_modules\mongodb-core\node_modules\kerberos
gyp ERR! node -v v4.0.0
gyp ERR! node-gyp -v v3.0.1
gyp ERR! not ok
mongodb@2.0.43 node_modules\mongodb
├── readable-stream@1.0.31 (string_decoder@0.10.31, isarray@0.0.1, inherits@2.0.1, core-util-is@1.0.1)
├── es6-promise@2.1.1
└── mongodb-core@1.2.12 (bson@0.4.12, kerberos@0.0.14)
Jay
  • 9,189
  • 12
  • 56
  • 96

2 Answers2

5

Yes, Python is required.

You need to install version 2.7. Also you need to set the PYTHON environment variable to e.g. c:\python27\python.exe (make sure it es accessible from your command line running env p)

You need to have Visual Studio (C++) installed, the free Express version is ok.

Depedending on your Visual Studio version, you have to add this param to your npm install command:

npm install --msvs_version=<version> where <version> may be 2012, 2013 or 2015 for example.

The dependecy is introduced by node-gyp which is used by the Node.js MongoDb driver. A installation description for Windows can be found here (which shows slightly more details than this answer).

Alexander Zeitler
  • 11,919
  • 11
  • 81
  • 124
  • Many thanks I tried as per your steps and now get a different error and I have updated this in the question. – Jay Sep 21 '15 at 12:13
  • 1
    CL is the Visual Studio compiler. Maybe this helps: http://blogs.msdn.com/b/deva/archive/2015/03/25/after-migration-vs-2013-c-project-throws-error-trk0005-failed-to-locate-quot-cl-exe-quot-the-system-cannot-find-the-file-specified.aspx – Alexander Zeitler Sep 21 '15 at 15:18
  • 1
    I was having a similar issue here even after installing Visual Studio- I was able to get the installation to complete by running 'npm install mongodb' from a VS2015 command prompt. – evbailey Oct 01 '15 at 04:52
1

This problem is not related to mongodb driver but to node-gyp, which is tool to add binary modules to node. You can find many answers here on stackoverflow, just search for node-gyp and windows. You can find one of many answers here.

Community
  • 1
  • 1
ivoszz
  • 4,370
  • 2
  • 27
  • 27