AWS-IoT-SDK-JS-v2 连接问题 - AWS CRT 二进制文件不存在于以下任何位置

AWS-IoT-SDK-JS-v2 connection problem - AWS CRT binary not present in any of the following locations

我正在尝试通过 aws-iot-sdk-js-v2 连接到 AWS IoT Core,当我 运行 PubSub example 时收到以下错误,如下所述:

/home/pi/aws-iot-device-sdk-js-v2/node_modules/aws-crt/dist/native/binding.js:60
    throw new Error("AWS CRT binary not present in any of the following locations:\n\t" + search_paths.join('\n\t'));
    ^

Error: AWS CRT binary not present in any of the following locations:
        /home/pi/aws-iot-device-sdk-js-v2/node_modules/aws-crt/dist/bin/native/aws-crt-nodejs
        /home/pi/aws-iot-device-sdk-js-v2/node_modules/aws-crt/dist/bin/linux-arm/aws-crt-nodejs
    at Object.<anonymous> (/home/pi/aws-iot-device-sdk-js-v2/node_modules/aws-crt/dist/native/binding.js:60:11)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/home/pi/aws-iot-device-sdk-js-v2/node_modules/aws-crt/dist/native/crt.js:22:35)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)

我有一个Raspberry Pi3B+

PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

我尝试了这里的解决方案 aws-iot-device-sdk-js-v2 #119 但没有任何帮助。

我按照 AWS IoT 中的描述进行了 onnecting-to-existing-device,但仍然出现此错误。

命令我运行(在删除我的raspi上的所有服务后的顺序)尝试按以下顺序安装和更新后:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install cmake
sudo apt-get install libssl-dev
sudo apt-get install -y nodejs
restarted by sudo shutdown -r 0
cd ~
npm install aws-crt
npm install aws-iot-device-sdk-v2
cd ~
git clone https://github.com/aws/aws-iot-device-sdk-js-v2.git
cd ~/aws-iot-device-sdk-js-v2
npm install
cd ~
mkdir certs
(I copied the certs and changed the name accordingly...)
cd ~/aws-iot-device-sdk-js-v2/samples/node/pub_sub
npm install
node dist/index.js --topic topic_1 --root-ca ~/certs/Amazon-root-CA-1.pem --cert ~/certs/device.pem.crt --key ~/certs/private.pem.key --endpoint <endpoint>
 (I swap the <endpoint> with my own....)

顺便说一句 the aws-iot-device-sdk-python-v2 可以,但我更喜欢使用 node.js SDK...

我在 aws-iot-device-sdk-js-v2 上打开了 new issue,但我仍在等待答案。

请帮忙。

我在 aws-iot-device-sdk-js-v2 repository from jmklix 中收到了解决我问题的答案:

目前,包的维护者不包含 raspberry pi 的预编译二进制文件,但如果需要,我们可以手动执行此操作。 aws-crt-nodejs:

中描述
git clone https://github.com/awslabs/aws-crt-nodejs.git
cd aws-crt-nodejs
git submodule update --init
npm install

然后我们需要将aws-crt-nodejs.node复制到错误信息中提到的位置:

cp -r ~/aws-crt-nodejs/dist/bin/linux-arm ~/aws-iot-device-sdk-js-v2/node_modules/aws-crt/dist/bin/linux-arm

解决了我的问题。