NodeJs 错误 - 无法加载 gRPC 二进制模块,因为它没有为当前系统预期目录安装?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49758008/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NodeJs Error - Failed to load gRPC binary module because it was not installed for the current system Expected directory?
提问by Sudhanshu Gaur
I am running my NodeJs App and i am getting an error.
我正在运行我的 NodeJs 应用程序,但出现错误。
sudo /usr/local/bin/node app.js
Error: Failed to load gRPC binary module because it was not installed for the current system
Expected directory: node-v57-linux-x64-glibc
Found: [node-v59-linux-x64-glibc]
This problem can often be fixed by running "npm rebuild" on the current system
Original error: Cannot find module '/home/projects/kj_app/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc
/grpc_node.node'
at Object.<anonymous> (/home/projects/kj_app/node_modules/grpc/src/grpc_extension.js:53:17)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/projects/kj_app/node_modules/grpc/src/client.js:37:12)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
Edit
编辑
sudo /usr/local/bin/npm rebuild
> [email protected] postinstall /home/projects/kj_app/node_modules/protobufjs
> node scripts/postinstall
> [email protected] install /home/projects/kj_app/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library
[grpc] Success: "/home/projects/kj_app/node_modules/grpc/src/node/extension_binary/node-v59-linux-x64-glibc/grpc_node.node" al
ready installed
Pass --update-binary to reinstall or --build-from-source to recompile
> @google-cloud/[email protected] install /home/projects/kj_app/node_modules/@google-cloud/profiler
> node-gyp rebuild
gyp ERR! clean error
gyp ERR! stack Error: EACCES: permission denied, rmdir 'build'
gyp ERR! System Linux 4.9.0-6-amd64
gyp ERR! command "/opt/bitnami/nodejs/bin/.node.bin" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "
rebuild"
gyp ERR! cwd /home/projects/kj_app/node_modules/@google-cloud/profiler
gyp ERR! node -v v9.8.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @google-cloud/[email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @google-cloud/[email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-04-10T16_06_40_444Z-debug.log
回答by Tnc Andrei
It seems like you have some verion conflict
好像你有一些版本冲突
Expected directory: node-v57-linux-x64-glibc
Found: [node-v59-linux-x64-glibc]
Have you tried running npm rebuildin your app folder?
您是否尝试过在您的应用程序文件夹中运行npm rebuild?
回答by guya
回答by Mnebuerquo
I had the same problem (using nvm) and found that my selected node version was different than the one in .nvmrc. I did the following steps to fix it:
我遇到了同样的问题(使用 nvm),发现我选择的节点版本与.nvmrc. 我做了以下步骤来修复它:
rm -rf node_modules
nvm use
yarn
I removed node_modules because it might have installed a version of some dependencies for the wrong version of node, so I want to ensure I have the correct libraries for the selected version.
我删除了 node_modules 是因为它可能为错误版本的节点安装了某些依赖项的版本,所以我想确保我拥有所选版本的正确库。
When I do nvm use, it picks the version of node from the .nvmrcin my project.
当我这样做时nvm use,它会从.nvmrc我的项目中选择节点的版本。
You can use npm installinstead of yarn. That's just how my project is set up.
您可以使用npm install代替yarn. 我的项目就是这样设置的。
回答by Sean Stayns
I had the same problem with Google Cloud Functions and Emulator, after migration from node 6 to node 8.
从节点 6 迁移到节点 8 后,我在使用 Google Cloud Functions 和 Emulator 时遇到了同样的问题。
My Solution:
我的解决方案:
npm rebuild// no effect- delete node_modulesfolder in the functionsfolder
npm install- in the functionsfolder call:
npm i --save firebase-functions firebase serve// start the emulator and try
npm rebuild// 没有效果- 删除功能文件夹中的node_modules文件夹
npm install- 在函数文件夹中调用:
npm i --save firebase-functions firebase serve// 启动模拟器并尝试
回答by DeeZone
By any chance did you do a npm installin your local (node-v59) when it should have been done on the container (node-v57)? The grpc binary is for the wrong version of node thus the error. In the case of the question, it looks like a local Mac (OSX - a flavour of Linux) running linux in a Docker container.
您是否有机会npm install在本地 ( node-v59) 中执行了本应在容器 ( node-v57) 上执行的操作?grpc 二进制文件用于错误版本的节点,因此错误。在这个问题的情况下,它看起来像是在 Docker 容器中运行 linux 的本地 Mac(OSX - Linux 的一种)。
Expected directory: node-v57-linux-x64-glibc
Found: [node-v59-linux-x64-glibc]
The solution would be to rm -fr node_modulesand do npm installin the container.
解决方案是在容器中rm -fr node_modules执行和执行。npm install
回答by cristianorbs
After trying many things I ended up doing the following (based on other answer):
在尝试了很多事情之后,我最终做了以下事情(基于其他答案):
- Updated node to latest version
- Updated npm to latest version
- npm rebuild on the project
- 将节点更新到最新版本
- 将 npm 更新到最新版本
- 项目上的 npm 重建
回答by exmaxx
I had a similar problem (but on the frontend, with Jest, Firebase and NVM). So this might not directly solve the original question but might help others who came here.
我遇到了类似的问题(但在前端,使用 Jest、Firebase 和 NVM)。所以这可能不会直接解决最初的问题,但可能会帮助到这里的其他人。
Check versions
检查版本
Try to call these and see if node versions in the paths match:
尝试调用这些并查看路径中的节点版本是否匹配:
which node
which npm
In my case also:
就我而言:
which firebase
Webstorm
网络风暴
In my case, I ran into this problem when using Webstorm, Jest, and Firebase, and I wanted to run the tests using Webstorm's tools.
就我而言,我在使用 Webstorm、Jest 和 Firebase 时遇到了这个问题,我想使用 Webstorm 的工具运行测试。
It was a problem with my "Jest Run Configuration". It pointed to a different version of Nodethan I was using as a default for the system.
我的“Jest Run Configuration”有问题。它指向的 Node 版本与我作为系统默认使用的版本不同。
回答by Noor Khan
following command worked for me
npm rebuild --unsafe-perm --build-from-sourceReference: https://docs.oracle.com/en/cloud/paas/blockchain-cloud/user/use-hyperledger-fabric-sdks-develop-applications.html#GUID-59A8279E-7A90-4823-9538-EA236BF9D164
以下命令对我
npm rebuild --unsafe-perm --build-from-source有用 参考:https: //docs.oracle.com/en/cloud/paas/blockchain-cloud/user/use-hyperledger-fabric-sdks-develop-applications.html#GUID-59A8279E-7A90-4823 -9538-EA236BF9D164

