javascript - NodeJS 找不到模块 'grpc'

标签 javascript node.js raspberry-pi3

我试图在我的树莓派 3 上运行一个 JS 脚本,但我一直回到一个似乎是“grpc”模块的问题。

我已经尝试在 https://github.com/firebase/firebase-tools/issues/442 之后重新安装和重建 npm该线程中的一些建议答案,但我一直返回到相同的错误消息,如下所示。

有没有人有在树莓派上用 JS 运行 firbase 的经验,谁知道如何解决这个问题?当我在 JS 文件中连接到我的 firebase 时,这似乎只是一个问题。

    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._compile (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)

最佳答案

我的解决方法是首先使用以下方法从 pi 的库中删除我的 node_modules:

sudo rm -rf node_modules

在我的项目文件夹中。 然后重新安装模块

npm install

但仍然缺少 grpc 模块,但安装它:

sudo npm install grpc

为我解决了这个问题。

关于javascript - NodeJS 找不到模块 'grpc',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50604566/

相关文章:

javascript - 函数返回的 API 响应返回未定义

javascript - 为不同的字母设置适当的边距?

c++ - 从 Arduino 到 Raspberry Pi 的不可靠 SPI 字节数组传输

python - 将大空格键与 Raspberry Pi 连接

javascript - Uncaught ReferenceError : Invalid left-hand side in assignment when trying to assign a sum to value

javascript - 有什么方法可以从函数外部访问变量名作为函数的参数?

node.js - Postgres 不接受使用 docker-compose 的其他容器的任何连接

javascript - NodeJS 错误回调已被调用

c - NodeJs 和 C 子进程之间通信的最佳方式

serial-port - 无法使用 Node-RED v0.17.3 读取 Raspberry Pi 3 上的 XBee Api 框架