Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson: Failed to load c++ bson extension, using pure JS version

前端 未结 30 2311
予麋鹿
予麋鹿 2020-11-28 02:19

I am getting the below error:

{ [Error: Cannot find module \'../build/Release/bson\'] code: \'MODULE_NOT_FOUND\' } 
  js-bson: Failed to load c++ bson extens         


        
30条回答
  •  隐瞒了意图╮
    2020-11-28 02:34

    find in npm module mongodb ..node_modules\mongodb\node_modules\bson\ext\index.js

    and change path to js version in catch block

    bson = require('../build/Release/bson');
    

    to bson = require('../browser_build/bson');

    try {
            // Load the precompiled win32 binary
            if(process.platform == "win32" && process.arch == "x64") {
              bson = require('./win32/x64/bson');  
            } else if(process.platform == "win32" && process.arch == "ia32") {
              bson = require('./win32/ia32/bson');  
            } else {
             bson = require('../browser_build/bson');  
            }   
        } catch(err) {
            // Attempt to load the release bson version
            try {
                bson = require('../browser_build/bson');
            } catch (err) {
                console.dir(err)
                console.error("js-bson: Failed to load c++ bson extension, using pure JS version");
                bson = require('../lib/bson/bson');
            }
        }
    

提交回复
热议问题