最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - NodeJS cannot find module 'grpc' - Stack Overflow

programmeradmin6浏览0评论

Im trying to run a JS script on my raspberry pi 3 but i keep returning to a problem which appears to be the "grpc" module.

i have tried reinstalling and rebulding npm following som of the proposed answers in this thread, but i keep returning to the same error message as shown below.

Does anyone have experience with firbase running in JS on raspberry pi who know how to fix this, it appears only to be a problem when i have the connection to my firebase in the JS file.

    module.js:557
    throw err;
    ^

Error: Cannot find module 'grpc'
    at Function.Module._resolveFilename (module.js:555:15)
    at Function.Module._load (module.js:482:25)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/pi/itPDP2018/node_modules/@firebase/firestore/dist/index.node.cjs.js:10:12)
    at Module._pile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)

Im trying to run a JS script on my raspberry pi 3 but i keep returning to a problem which appears to be the "grpc" module.

i have tried reinstalling and rebulding npm following https://github./firebase/firebase-tools/issues/442 som of the proposed answers in this thread, but i keep returning to the same error message as shown below.

Does anyone have experience with firbase running in JS on raspberry pi who know how to fix this, it appears only to be a problem when i have the connection to my firebase in the JS file.

    module.js:557
    throw err;
    ^

Error: Cannot find module 'grpc'
    at Function.Module._resolveFilename (module.js:555:15)
    at Function.Module._load (module.js:482:25)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/pi/itPDP2018/node_modules/@firebase/firestore/dist/index.node.cjs.js:10:12)
    at Module._pile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
Share Improve this question asked May 30, 2018 at 12:21 Rasmus HvilshøjRasmus Hvilshøj 711 gold badge1 silver badge5 bronze badges 5
  • 1 Have you confirmed it works on your puter? If not, then you really shouldn't try to make raspberry and other unrelated things part of the problem. – FINDarkside Commented May 30, 2018 at 12:23
  • i testet everything before pushing to the pi. It seems to be somekind of libary problem on the pi, but as im fairly new to the raspberry world i dont know how to fix this – Rasmus Hvilshøj Commented May 30, 2018 at 12:30
  • Have you tried installing the newest version of firebase-tools? According to one of the ments, grpc is no longer a dependency. Do you get any errors when installing firebase-tools on the raspberry? – FINDarkside Commented May 30, 2018 at 12:32
  • I reinstalled the firebase-tool with sudo acces, and then ran npm install grpc and now it works, this whas the first thing i did 8 hours ago but now it works! – Rasmus Hvilshøj Commented May 30, 2018 at 13:26
  • 1 Ok, I'd say you should answer your own question and accept the answer, in case anyone else ends up on this question. – FINDarkside Commented May 30, 2018 at 13:28
Add a ment  | 

2 Answers 2

Reset to default 5

The fix for me was to first remove my node_modules from the pi's libary using:

sudo rm -rf node_modules

in my project folder. Then reinstalling the modules with

npm install

but still the grpc module was missing, but installing it with:

sudo npm install grpc

fixed the problem for me.

The new way is this.

npm i @grpc/grpc-js
发布评论

评论列表(0)

  1. 暂无评论