모듈 '../build/Release/bson'을 찾을 수 없습니다.] 코드 : 'MODULE_NOT_FOUND'} js-bson : 순수 JS 버전을 사용하여 c ++ bson 확장을로드하지 못했습니다.
아래 오류가 발생합니다.
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
내 버전 세부 정보는 다음과 같습니다.
운영체제 : Windows 7
MongoDB : 2.6.5
노드 : 0.12.0
여기에 문제를 게시하기 전에 이러한 것들을 시도했습니다.
나는에 가서
\node-modules\mongoose\node-modules\mongodb\node-modules\bson
폴더에서 바인딩 활력 파일에 변경하려면 아래 만들어'include_dirs': [ '<!(node -e "require(\'nan\')")' ]
에'include_dirs': ["<!(nodejs -p -e \"require('path').dirname(require.resolve('nan'))\")"]
이 명령을 실행
npm install -g node-gyp
몽구스 버전을 3.8.21로 업데이트했습니다.
package.json
아무것도 작동하지 않습니다. 제안 해주세요
npm 모듈 mongodb에서 찾기 :
.. \ node_modules \ mongodb \ node_modules \ bson \ ext \ index.js
catch 블록에서 js 버전으로 경로를 변경하십시오.
bson = require('../build/Release/bson');
에:
bson = require('../browser_build/bson');
또는 다음 위치에 파일을 복사하십시오.
.. \ node_modules \ bson \ build \ Release \ bson
에서:
.. \ node_modules \ bson \ browser_build \ bson
오늘이 문제가 있었으며 (2016 년 2 월 19 일) 최신 버전의 몽구스를 설치하여 해결했습니다. 이것을 package.json에 넣으십시오.
"mongoose": "~4.4"
희망이 도움이됩니다. 나를 위해 해결했습니다!
문제는 npm을 통해 mongoose를 설치할 때 Windows에 파이썬이 설치되어 있다고 가정하고 필요한 라이브러리를 작성하려고 시도한다는 것입니다. 파이썬이 없기 때문에 경고와 함께 빌드 단계를 건너 뜁니다. 그러나 응용 프로그램을 시작할 때 필요한 모듈이 없으므로이 오류가 발생합니다.
https://www.python.org/downloads/ 에서 컴퓨터에 python (버전 2.7)을 설치하거나 chockolatey를 설치 한 경우을 입력하십시오 choco install python2
.
그런 다음 파이썬 변수가 설정되어 있는지 확인하십시오. 명령 프롬프트에서 다음과 같이 설정할 수 있습니다.
SET python=D:\Python27\python.exe
(물론 파이썬의 위치에 따라 경로를 변경해야합니다) 그런 다음 node-gyp을 설치하십시오.
npm install -g node-gyp
이제 몽구스 또는 문제를 일으키는 모든 모듈을 다시 설치할 수 있습니다.
npm install mongoose
이번에는 빨간색 대신 노란색 선이 표시되지만 오류는 사라집니다.
mogoose 버전을 설치 하여이 문제를 해결했습니다. 3.8.23
npm install mongoose@3.8.23
이것은 나를 위해 일했습니다. 작업 공간에서 텍스트를 검색하십시오.
"../build/Release/bson"
당신은 아마도 몽구스와 몽크 모듈에서 그것을 찾을 것입니다.
그런 다음 각각을 교체하십시오.
bson = require('../build/Release/bson');
와:
bson = require('bson');
그게 다야!
시도 npm install mongoose@3.8.23
또한 교체 bson = require('../build/Release/bson');
에
bson = require('../browser_build/bson');
node_modules / bson / ext / index.js에서
이것은 나를 위해 일했다 :
파일로 이동하십시오 (프로젝트에서).
node_modules/mongoose/node_modules/mongodb/node_modules/bson/ext/index.js
변경 :
bson = require('../build/Release/bson');
에:
bson = require('bson');
참조 : https://github.com/mongodb/js-bson/issues/118
짧은 답변
최신 버전의 mongodb를 설치하십시오.
조금 더 답변
package.json이 최신 버전의 mongodb를 사용 중인지 확인한 후 node_modules / mongodb를 제거하고 npm 설치를 다시 수행하십시오. mongodb를 직접 종속성으로 사용하지 않은 경우 mongdb를 사용하는 패키지를 찾으십시오. 나는 사용했다 :
find . -type f -name package.json | xargs grep mongodb
...
./sails-mongo/package.json: "mongodb": "1.4.26",
...
그래서 ./sails-mongo/package.json을 다음과 같이 업데이트했습니다.
"mongodb": "2.1.7",
그런 다음 node_modules / mongodb를 제거하고 npm 설치를 다시 수행하십시오. 지금은 잘 보인다.
더 긴 답변
현재 제안 된 사용 방법이 마음에 들지 않습니다.
require('../browser_build/bson')
4k + 라인 파일 인 ../browser_build/bson.js를 살펴본 후 "비 네이티브"구현으로 보입니다. 따라서 불만을 제기하지는 않지만 여전히 "순수 JS 버전 사용"으로 인해 성능이 저하됩니다.
보면 https://github.com/mongodb/js-bson/issues/145 및 https://github.com/mongodb/js-bson/issues/165 문제가 발생 것처럼 것 같습니다 :
antoniofruci 님이 2015 년 9 월 15 일에 댓글을 달았습니다
방금 c ++ 코드가 6 개월 전에 옮겨졌으며 이제 선택적 종속성 인 bson-ext가 있음을 알았습니다. 실제로 최신 버전을 설치하면 오류가 발생하지 않습니다.
그래서 전체 node_modules를 제거하려고 시도했지만 여전히 같은 오류가 발생했습니다. node_modules / mongodb의 package.json을 보면 그 버전은 1.4.26이며 최신 2.1.7이 아닙니다.
분명히 내 mongodb는 내가 설치 한 다른 패키지 인 sails-mongo의 종속성으로 제공됩니다. sails-mongo의 package.json을 수정하고 npm 설치를 다시 실행하면 문제가 해결됩니다.
Keystone JS CMS 배포 동일한 오류가 발생했으며 가장 우아한 해결책은 다음과 같습니다.
설치 npm-check-updates
:
root@keystonejs:~# npm install -g npm-check-updates
키스톤 사이트 디렉토리 내에서 package.json
종속성을 확인하십시오.
debian@keystonejs:~/myproject/manalcjim$ npm-check-updates -u
그런 다음 모든 패키지를 업데이트하십시오.
debian@keystonejs:~/myproject/manalcjim$ npm install
마지막으로 jade
템플릿 을 선택한 경우 jade
모듈을 명시 적으로 설치해야 할 수도 있습니다 .
debian@keystonejs:~/myproject/manalcjim$ npm install jade --save
표시된 답변이 완전히 잘못되었습니다. 콘솔 로그 문을 숨기고 실제로 문제를 해결하는 것은 없습니다. 눈을 감 으면 같은 결과를 얻을 수 있습니다.
이 문제는 node-gyp에 의해서만 발생합니다. 그 목적은 bson과 같은 특정 모듈에 대한 기본 확장을 컴파일하는 것입니다.
If it fails to do so then the code will fallback to the JS version and kindly tell you so through the informative message:
Failed to load c++ bson extension, using pure JS version
I assume the question is really about how to compile the native C++ extension rather that just not seeing the message so let's address that.
In order for node-gyp to work your node-gyp must be up to date with your node and C++ compiler (that will differ based on your OS). Just as important your module must also be up to date.
First uninstall and reinstall node-gyp
npm un node-gyp -g;npm i node-gyp -g
Now you will need to fully uninstall and reinstall any node module in your app (that includes modules installed by requirements as well) that have bson. That should take care of the error. You can search for 'Release/bson' and find the culprits.
find node_modules/ -type 'f' -exec grep -H 'Release/bson' {} \;
And then uninstall and reinstall these modules.
전체 node_modules
폴더를 다시 실행하는 것이 더 쉽습니다 .
rm -rf node_modules
npm cache clear
npm i
여전히 문제가 발생하면 1) 모듈이 오래되었습니다-저장소에서 문제 추적기를 확인하거나 2) 잠재적 충돌이 있습니다-때로는 로컬 노드-gyp가있을 수 있습니다. node-gyp
자체적으로 실행 하고 버전을 확인할 수 있습니다.
www.spotdekho.com
새 windows10
컴퓨터 에서 설정을 작성하는 동안 "nodemon web.js"
동일한 오류로 인해 명령을 실행할 수 없습니다
"오류 : '../build/Release/bson'모듈을 찾을 수 없습니다"
아래 단계로 수정했습니다.
- "node_modules \ bson \ build \"위치에 "릴리스"폴더를 만듭니다.
- "node_modules \ bson \ browser_build \"에서 bson.js를 복사하십시오.
- "node_modules \ bson \ build \ Release"폴더에 bson.js를 붙여 넣습니다.
문제가 해결됩니다.
추신 : 몽구스 버전 4.8.8을 사용하고 있습니다.
Thanks :) , hope it helps someone .
In my case, the bits that come with mongoose (npm install mongoose
) have a working version of the mongodb
package in its node_modules
folder.
The following steps saved me the work of troubleshooting the issue:
npm install mongoose
- copy
node_modules\mongoose\node_modules\mongodb
to my rootnode_modules
folder (overwriting any version that came withnpm install mongodb
) - ignore the
Failed to load c++ bson extension...
error (or change the code to be silent on the issue)
When I was getting errors like this, I was upgrading from node v0.10 to node v4.x.x . What I had to do was install a newer version of gcc (I think I had gcc v4.4.x or something). I updated to gcc 4.7.2 and things worked after that.
I also had the same problem with bson.
trying a newer mongoose version
npm install mongoose@4.4
solved the issue.
Massimo.
Run this command to uninstall mongoose npm uninstall --save mongoose
- thereafter reinstall it but this time npm
automatically installs the latest version of mongoose run npm install --save mongoose
This worked for me.
Unfortunately, All the above answers are only half right.. Took a long time to figure this out..
Mongoose bson install via npm throws warning and causes the error...
npm install -g node-gyp
git clone https://github.com/mongodb/js-bson.git
cd js-bson
npm install
node-gyp rebuild
This works like magic!!
If you are using windows 8.1, you might want to make sure that you are installing your npm modules with the correct visual studio compiler.
I have Visual Studio 2012 installed, this command works for me. (after deleting node_modules dir)
npm install --msvs_version=2012
For some reason, node-gyp is trying to use the incorrect version of Visual Studio compiler. I also noticed that the "npm install" command was printing out a warnings about not node-gyp dependencies when installing the mongodb and mongoose modules.
After using the correct msvs_version, the npm install warnings went away as well as the console warning when running my nodejs app.
You might also want to make sure that you have the correct Python 2.7.X version installed and not Python 3.0.X.
You will also need to make sure that python is in your env path.
The only thing which helps me on Windows 7 (x64): https://stackoverflow.com/a/29714359/2670121
Reinstall node and python with x32 versions.
I spent many time with this error (Failed to load c++ bson extension) and finally, when I installed module node-gyp
(for build native addons) and even installed windows SDK with visual studio - nodejs didn't recognize assembled module bson.node as module. After reinstall the problem is gone.
Again, What means this error?
Actually, it's even not error. You still can use mongoose. But in this case, instead of fast native realization of bson module, you got js-realization, which slower. I saw many tips like: "edit path deep inside node_modules..." - which totaly useless because it's not solve the problem but just turned off the error messages.
Try this npm install bson
and npm update
You should never change files in NODE_MODULES library folder.
Those files are result of npm install
command.
Basicaly, I think for Windows users - right way is use VM. It's what I'm doing when I work from home.
All you need:
for CentOS: yum install gcc gcc-c++ make openssl-devel
for Debian/Ubuntu: apt-get install build-essential
and then npm install
or, if you have already done it - npm update
The best solution for me was to upgrade from node-mongodb 1.x to 2.x.
I realize this thread is 1 year + old, but it helped me, albeit with a different module.
I installed mongoose-post-findv0.0.2 and this issue started. To fix it, I used the suggestions and navigated to \node_modules\mongoose-post-find\node_modules\bson\ext and opened the index.js file.
The file starts off with a try catch block trying to require the correct bson version
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('../build/Release/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');
}
}
this is the corrected version. What was happening is it tried to load bson from ../build/Release/bson, couldn't find it and fell into the catch. There is tried to load bson again from ../build/Release/bson and of course failed. So I changes the path in the catch to look in ../browser_build/bson. This resolved the error.
I post this for completeness.
I had the same issue after upgrade version of ubuntu to 16.04. I solved in this way, hope it helps.
$rm -rf node_modules
$npm --save install bson
$npm --save install mongoose
$npm install
In our case, the reason that the c++ version bson was not found was because we were behind a corporate proxy and something in the BSON build process needs to reach out to fetch files. When we looked in node_modules/bson/builderror.log, we saw an error like this:
gyp WARN install got an error, rolling back install gyp ERR! configure error gyp ERR! stack Error: connect ECONNREFUSED gyp ERR! stack at errnoException (net.js:904:11) gyp ERR! stack at Object.afterConnect [as oncomplete] (net.js:895:19)
Which suggested that the proxy might be the issue. Setting the http_proxy and https_proxy environment variables solved it.
Sorry for reawakening comments on this, but I wanted to post this for anyone else that hits this in the future since this thread was very helpful in solving our issue.
Tried npm install mongoose --msvs_version=2012, if you have multiple Visual installed, it worked for me
First copy bson.js
code from browser_build folder
second create new file bson.js
and paste code
third save the new file near to in index.js
.
I'm working with OS Windows 8.1 and I had the same problem. The source of the problem was the version of Python. I found the origin problem review the file ...\node_modules\mongodb\node_modules\mongodb-core\node_modules\kerberos\builderror.log.
I installed the correct version of Python (2.7.9 for 64 bits) and it resolved my problem.
Note: The installed version of python must be equal or greater than 2.7.5 and less than 3.0.0
I've tried bson = require('../browser_build/bson');
but end up running into another error
Cannot set property 'BSON_BINARY_SUBTYPE_DEFAULT' of undefined
Finally I fixed this issue simply by npm update
, this will fix the bson module in mongoose.
So, i have the same problem and it happens then the specified mongoDB URL doesn't exist. So, to fix this you need to go "..\server\config\environment" folder and edit in "development.js" file the link to mongoDB.
Example:
// Development specific configuration
// ==================================
module.exports = {
// MongoDB connection options
mongo: {
uri: 'mongodb://localhost/test2-dev'
},
seedDB: true
};
So, change this "uri: 'mongodb://localhost/test2-dev'" to some real path to your mongoDB database.
I will be glad if my post will help somebody...
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');
}
}
'IT' 카테고리의 다른 글
텍스트 영역 크기 조정을 비활성화하는 방법은 무엇입니까? (0) | 2020.06.06 |
---|---|
드롭 대 기존 드롭 대? (0) | 2020.06.06 |
Linux OOM 킬러가 종료 한 프로세스 찾기 (0) | 2020.06.06 |
svn에`revert-all` 명령이 있습니까? (0) | 2020.06.06 |
dict.clear ()와 파이썬에서 {} 할당의 차이점 (0) | 2020.06.06 |