Skip to main content

NPM install Errors: '../build/Release/bson' 'MODULE_NOT_FOUND' js-bson: Failed to load c++ bson extension, node-gyp.js rebuild, ENOENT




 ISSUE:
Node.js modules build errors
NPM install Errors:  '../build/Release/bson' 'MODULE_NOT_FOUND'  js-bson: Failed to load c++ bson extension, node-gyp.js rebuild, ENOENT

CAUSE:
Even  if python path is set in the Windows' environment variable and in the path, node-gyp is not picking the python path . If you type 'python' from any directory it might work. But node-gyp will still through these errors.  It is confusing as in CLI python works if you call python.exe, but node-gyp doesn't find it, so you decide to try on every thing else you can find online.

- If there is a C++ error , node-gyp rely on visual studio's C++ compiler to build. You might need to set Visual C++ path or version in the CLI command. 

- long directory or path name issue in Windows: Windows only can handle 260 charecters in a given path name (oooooooooops. This is not an easy fix for windows as the core OS is built on top of this limitation.) . You have to make it simpler path starting from C: or from tiny path names for your projects! (See one of the errors below.)

FIX:
node-gyp doesn't pick up python path from environment / the path is not defined correctly in environment variables.

set the environment variable PYTHON to your python.exe
set PYTHON=c:\Python27\python.exe" 

------ OR
set the npm configuration value like this,
 npm config set python = c:\Python27\python.exe

----- OR
C:\WINDOWS\system32>npm install YOUR-PACKAGE --python=C:\Python27\python.exe  

----- OR
If you get error on C++ compiler use --msvs_version = 20xx in the CLI command.

C:\WINDOWS\system32>npm install YOUR-PACKAGE --python=C:\Python27\python.exe  
--msvs_version=2013  (put your current version of Visual studio here)

You can also try ,
npm  cache clean  ( this might need you to start Command prompt with Admin permission)
npm install  YOURPACKAGE  --python=c:\python27\python.exe

So, TRY the above options before you try ,
uninstall ndoe, npm, python, node-gyp, 64 bit versions vs 32 bit versions ,
changing  code in the npm packages ,
or opening Ms command window - shell window in Admin mode,
etc. oops that would be a nightmare.




Errors:

Often the error is logged into a file like (node-gyp rebuild 2> builderror.log) - if you open this file under the relevant package's directory - you will see the same pattern of errors like,
gyp ERR! configure error
gyp ERR! stack Error: spawn C:\Python273 ENOENT
(see full errors below)

Some of these following node packages use node-gyp to build code at your system, and they through the below errors. 

bson  (mongodb, mongocore nodemodules - uses this package, any mongo driver mongo / mongoose will produce this error)
ws
Kerbros
node-gyp configure
 
> ws@0.5.0 install \AppData\Roaming\npm\node_modules\strongloop\n
ode_modules\strong-arc\node_modules\strong-mesh-client\node_modules\engine.io\no
de_modules\ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

 AppData\Roaming\npm\node_modules\strongloop\node_modules\strong-
 "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_mo
dules\node-gyp\bin\node-gyp.js" rebuild
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
 
====================
Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } 
  js-bson: Failed to load c++ bson extension, using pure JS version


=================== (You will see the same below log in the 'builderror.log')
C:\ >node-gyp configure --msvs
_version=2010
gyp info it worked if it ends with ok
gyp info using node-gyp@1.0.3
gyp info using node@0.12.0 | win32 | ia32
gyp ERR! configure error
gyp ERR! stack Error: spawn C:\Python273 ENOENT
gyp ERR! stack     at exports._errnoException (util.js:746:11)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1046
:32)
gyp ERR! stack     at child_process.js:1137:20
gyp ERR! stack     at process._tickCallback (node.js:355:11)
gyp ERR! stack     at Function.Module.runMain (module.js:503:11)
gyp ERR! stack     at startup (node.js:129:16)
gyp ERR! stack     at node.js:814:3
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok


===================
gyp: binding.gyp not found (cwd: C:\ \ \NodeWorkspace\Tutorials\loopbackinter\node_modules\loopback-connector-mongodb\node_modules\mongodb\node_modules\mongodb-core\node_modules\bson) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:343:16)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\ \NodeWorkspace\Tutorials\loopbackinter\node_modules\loopback-connector-mongodb\node_modules\mongodb\node_modules\mongodb-core\node_modules\bson
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok


=================
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(25
3,5): error MSB3491: Could not write lines to file "Release\obj\bson\bson.lastb
uildstate". The specified path, file name, or both are too long. The fully qual
ified file name must be less than 260 characters, and the directory name must b
e less than 248 characters. [C:\Users\xxx\ \loopback-getting-started-intermediate-master\node_modules\loopback-connector-mo
ngodb\node_modules\mongodb\node_modules\mongodb-core\node_modules\bson\node_mod
ules\bson-ext\build\bson.vcxproj]

========================
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xlocale(323): wa
rning C4530: C++ exception handler used, but unwind semantics are not enabled.
Specify /EHsc [C:\Users\loopback-inter
mediate\node_modules\loopback-connector-mongodb\node_modules\mongodb\node_modul
es\mongodb-core\node_modules\kerberos\build\kerberos.vcxproj]
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xlocale(323): wa
rning C4530: C++ exception handler used, but unwind semantics are not enabled.
Specify /EHsc [C:\Users\loopback-inter
mediate\node_modules\loopback-connector-mongodb\node_modules\mongodb\node_modul
es\mongodb-core\node_modules\kerberos\build\kerberos.vcxproj]

=============
 C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale(337): wa
rning C4530: C++ exception handler used, but unwind semantics are not enabled.
Specify /EHsc
[C:\Users\ \ \NodeWorkspace\Tutorials\loopbackinter\
node_modules\loopback-connector-mongodb\node_modules\mongodb\node_modules\mongo
db-core\node_modules\bson\node_modules\bson-ext\build\bson.vcxproj]
..\ext\bson.cc(809): warning C4530: C++ exception handler used, but unwind sema
ntics are not enabled. Specify /EHsc [C:\Users  \NodeWorkspace\T
utorials\loopbackinter\node_modules\loopback-connector-mongodb\node_modules\mon
godb\node_modules\mongodb-core\node_modules\bson\node_modules\bson-ext\build\bs
on.vcxproj]

============
c:\users\  \nodeworkspace\tutorials\loopbackinter\node_modules\lo
opback-connector-mongodb\node_modules\mongodb\node_modules\mongodb-core\node_mo
dules\bson\node_modules\bson-ext\node_modules\nan\nan_new.h(209): warning C4244
: 'argument' : conversion from 'int64_t' to 'double', possible loss of data
[C:
\Users\ NodeWorkspace\Tutorials\loopbackinter\node_modules\loop
back-connector-mongodb\node_modules\mongodb\node_modules\mongodb-core\node_modu
les\bson\node_modules\bson-ext\build\bson.vcxproj]

Comments

Popular posts from this blog

LLM on Mobile Phone : Mini Universal data and assistant running on an android smart phone Galaxy S23

  Imagine a world where everyone has access to a mini #OpenAI's #ChatGPT on their mobile phone, answering any question on any topic, right from their local phone memory. No need for internet. This is the future of #LLMs on mobile devices, and it's happening now. #MLC-AI has created a way to install a 3 billion parameter #RedPajam #LLMModel on a #Galaxy #S23 smartphone. This is a powerful #LLM that can generate text, translate languages, write different kinds of creative content, and answer your questions in an informative way. And it's all available on your phone, without the need for an internet connection. This could have a profound impact on people all over the world. Millions of suburban students who don't have access to the internet could now have access to a universal data source that can answer most of their questions. Refugee camps around the world could also benefit from this technology, giving refugees access to information and resources that they might not ot...

Javascript 3 dimentional matrix html board onclick empty current box

javascript 3 dimentional matrix html board onclick empty current box  Algorithm! Rules: 1. Only immediate Box can be swapped. Should not jump another box 2. Only directions allowed: Left, Right, Up, Down. 3. Should not swap diagonally.   See the Pen 3d matrix map numbers. by PV ( @moorthi07 ) on CodePen .   function hasClass(elem, className) {   return elem.className.split(" ").indexOf(className) > -1; } function addClick() {   var btn = '<button class="btn1">kkkkk</button>';   document.getElementById("container").innerHTML += btn; } // function boxbodyClick(obj) { //   /* console.log(';;;',obj.className) */ //   /* alert(obj) */ // } var arr = [3]; for (var i = 0; i < 3; i++) {   arr[i] = new Array(3); } var emti = 0; var emtj = 0; function btnClick(obj, i, j) {   if (arr[i][j] !== "-") {            if (j + 1 == emtj || j == emtj || j - 1 == emtj)...

Agentic AI growth could make GenAI providers to charge $1000-$2000 per month - #Cathywood , here is how.

      #Cathywood predicts that as the #agenticgenai grows the #GenAI service providers like openai, gemini, Copilot, etc will be able to charge $1000 - $2000 per month to their business customers. And she adds, "this is going to happen". Why this is important: Remember #Cathywood made a monster call in 2018, predicting that Tesla would hit $4,000 in five years. And eventually Tesla hit Wood's price target, with shares closing at $816, or $4,080 on a split adjusted basis (Jan. 2021). How this could happen: #AgenticGenAi means , 1. Integrating a business service with GenAI providers like Gemini/ChatGPT as an agent and make available in the chat interface. 2. Less human interaction and more calls to the GENAI Models. Nothing totally new, its similar to 'Ok google play a song from spotify' 'Alexa, order 8 pack dove on amazon' For example, when booking a flight, instead of navigating a complex travel website, users can simply provide a text prompt...