Raspberry Pi Zero W 上的 Node.js,依赖项不会自动下载

Posted

技术标签:

【中文标题】Raspberry Pi Zero W 上的 Node.js,依赖项不会自动下载【英文标题】:Node.js on a Raspberry Pi Zero W with dependencies not downloading automatically 【发布时间】:2020-05-22 22:56:28 【问题描述】:

我制作了一个 Discord 机器人,我想将它托管在 Pi 上,但是一旦我让 node.js 工作,我就遇到了安装 npm 的墙,但依赖项不会随它一起下载。有人可以帮我吗?

代码

pi@raspberrypi:~/bot $ npm i discord.js
npm WARN deprecated snekfetch@3.6.4: use node-fetch instead
npm WARN discord.js@11.1.0 requires a peer of bufferutil@^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.1.0 requires a peer of erlpack@hammerandchisel/erlpack but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.1.0 requires a peer of node-opus@^0.2.5 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.1.0 requires a peer of opusscript@^0.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.1.0 requires a peer of sodium@^2.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.1.0 requires a peer of libsodium-wrappers@^0.5.1 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.1.0 requires a peer of uws@^0.14.1 but none is installed. You must install peer dependencies yourself.
npm WARN greeter-bot@1.0.0 No repository field.
npm WARN greeter-bot@1.0.0 No license field.

+ discord.js@11.1.0
updated 1 package in 24.205s

【问题讨论】:

如果我是你,我会检查你的依赖关系的架构。例如,Mongo 只能使用 x86 处理器,而 raspberry 是 ARM。如果我是对的,请告诉我,以便我详细说明。 【参考方案1】:

我先把我电脑上的 npms 安装到一个特定的文件夹,然后用 Filezilla 转移它来修复它

【讨论】:

这是一个非常具体的解决方案。我的回答对您和其他有此问题的人都有效。请编辑您的问题以包含与我类似的解决方案,或者只是接受我的。 Stack Overflow 是一个社区网站,因此,这个问题和答案应该可供其他用户使用,而这个答案不是。【参考方案2】:

首先,我不建议在 Raspberry Pi 上托管 Discord 机器人,但为了与您的问题保持一致,我假设您坚持这样做。

你可以尝试两件事:

如果您安装了apt,请运行命令apt install -a,这将安装之前输出中缺少的所有包。

第二种方法是手动安装它说丢失的包。

转到npm repository,搜索丢失的包,然后在输出中下载它请求的版本。

希望这会有所帮助!

【讨论】:

好吧,我解决了问题,他选择了不同的路线。

以上是关于Raspberry Pi Zero W 上的 Node.js,依赖项不会自动下载的主要内容,如果未能解决你的问题,请参考以下文章

如何从 Raspberry Pi Zero 向 PC 发送实时传感器数据?

无显示器安装raspberry zero w树莓派 zero w

Android Things:Raspberry Pi 上的 ADB over USB

Python flask-cors ImportError: No module named 'flask-cors' Raspberry pi

sh 修复了Raspberry Pi上的慢速鼠标

Raspberry pi 上的 Alsa 问题