awslabs/aws-crt-nodejs

Installing on Raspberry Zero W

markusl opened this issue · 3 comments

Hi,

I'm receiving the following error when trying to install the library on Raspberry Zero W with Node.js v16.17.0.

npm WARN deprecated node-pre-gyp@0.15.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future
npm ERR! code 1
npm ERR! path /home/pi/example/node_modules/aws-crt
npm ERR! command failed
npm ERR! command sh /tmp/install-4ef19b8a.sh
npm ERR! /home/pi/example/node_modules/aws-crt/scripts/build.js:154
npm ERR!     if (fs.existsSync(nativeSourceDir)) {
npm ERR!                       ^
npm ERR!
npm ERR! ReferenceError: nativeSourceDir is not defined
npm ERR!     at buildFromRemoteSource (/home/pi/example/node_modules/aws-crt/scripts/build.js:154:23)
npm ERR!     at main (/home/pi/example/node_modules/aws-crt/scripts/build.js:193:13)
npm ERR!     at Object.<anonymous> (/home/pi/example/node_modules/aws-crt/scripts/build.js:205:3)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1126:14)
npm ERR!     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:1004:32)
npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:839:12)
npm ERR!     at Module.require (node:internal/modules/cjs/loader:1028:19)
npm ERR!     at require (node:internal/modules/cjs/helpers:102:18)
npm ERR!     at Object.<anonymous> (/home/pi/example/node_modules/aws-crt/scripts/install.js:20:1)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1126:14)
npm ERR!     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:1004:32)
npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:839:12)
npm ERR!     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
npm ERR!     at node:internal/main/run_main_module:17:47

Do you happen to have an idea why this is happening and how to fix this?

package.json contains following entries:

    "aws-crt": "^1.14.3",
    "aws-iot-device-sdk-v2": "^1.8.7",

The code works just fine on a macOS.

Same here with node v18.8.0 on a raspi zero w.

Thank you for letting us know of this issue! I have a PR to fix the issue.

In the meantime, you can fix the issue locally by going to node_modules/aws-crt/scripts/build.js, opening it in a text editor, and moving line const nativeSourceDir = "crt/"; (should be at line 188) to line 15 (just below the const tar = require("tar") so it is globally defined. This should fix the issue and allow you to build it on the Raspberry Pi 🙂

Version 1.14.4 was just released with the fix and should soon be available in NPM.
Edit: Fixed in the Javascript SDK as well in release v1.8.8