Open prakashmallow opened 2 months ago
I am also facing the same issue with aws-iot-device-sdk-v2
package. When I import iot
and mqtt
in an Next.js application and while running the app below error is thrown.
Error: AWS CRT binary not present in any of the following locations:
/bin/darwin-arm64-cruntime/aws-crt-nodejs.node
at eval (webpack-internal:///./node_modules/aws-crt/dist/native/binding.js:110:11)
I'm looking into this, and I think part of the problem is that you are trying to use the node functions of this sdk rather than the browser functions. You can fix this by adding the browser path to your tsconfig.json:
"paths": {
"aws-iot-device-sdk-v2": ["./node_modules/aws-iot-device-sdk-v2/dist/browser"]
}
I'm still getting some other errors when trying to run the pub_sub_mqtt5 inside a next.js app, so I'm still looking into this.
@jmklix My Next.js app is running with JSX components instead of TSX. I'm encountering an issue where the @module-federation/nextjs-mf npm package is causing problems. When I remove the @module-federation/nextjs-mf npm package from my app, it works fine with aws-iot-device-sdk-v2. However, my application requires the @module-federation/nextjs-mf npm package
I think Next.js allows you to specify the library paths through jsconfig.json
.
Reference: https://nextjs.org/docs/app/building-your-application/configuring/absolute-imports-and-module-aliases
@xiazhvera @jmklix After applying the changes mentioned in the jsconfig.json file, I'm still encountering the same issue.
Can you provide more detailed steps for setting up nextjs app?
I can get the next.js getting started app working when I combine it with the pub_sub_mqtt5 sample from this repo, while making only a few minor changes. I can also provide more detailed steps on how I set that up if you would like (it's in TS not JS).
@jmklix
https://github.com/hari-prasad-a/mqtt-container-app https://github.com/hari-prasad-a/mqtt-child-app
Please clone the above repositories with all the settings already completed for the Next.js apps. Follow the below steps:
@jmklix Please check this comment and give guidances for how to configure aws-iot-device-sdk-v2
on webpack config.externals on Nextjs app
@jmklix any update?
It seems like the issue more related to a webpack configuration rather than a problem with our SDK. I'm not positive if we would have a good solution for it. Unfortunately, I'm a bit short to dive deeper into it right now. I'll be able to revisit the issue in two weeks.
I made several attempts to fix the issue following the suggestions mentioned in module-federation, but unfortunately, I wasn't able to resolve it. Currently, I don't have a viable solution for this problem. I'll leave the issue open in case anyone has further updates or suggestions.
I don't think this is isolated to NextJS. I'm using Webpack 5.92.0 to package up a module, running on OS X Sonoma 14.5, with Node 16.16.0. Importing a module from aws-iot-device-sdk-js-v2 seems be what initiates the issue.
The problem seems to be in how a path is loaded in aws-crt. Here's a Webpack build warning that seems related:
WARNING in ./node_modules/aws-crt/dist/native/**binding.js 104**:18-31
Critical dependency: the request of a dependency is an expression
@ ./node_modules/aws-crt/dist/native/auth.js 20:34-54
@ ./node_modules/aws-crt/dist/index.js 42:26-50
@ ./node_modules/aws-iot-device-sdk-v2/dist/index.js 53:18-36
@ ./main.js 1:0-44
I've attached a very basic project that also shows the issue: aws-crt-problem.zip
@xiazhvera @jmklix Any update on this issue? I have more dependencies with this AWS IoT package. When will this issue be fixed, or can we look for an AWS IoT alternative?
Describe the bug
I facing an issue while installing the
aws-iot-device-sdk-v2
package. After importingiot
andmqtt
, I attempt to run the Next.js app usingnpm run dev
but encounter the below errorsExpected Behavior
After importing
iot
and 'mqttfrom
aws-iot-device-sdk-v2` the nextjs app running as we expect normallyCurrent Behavior
Currently, it's throwing the below error we can
import { it, mqtt } from 'aws-iot-device-sdk-v2'
on the Nextjs app component and run on it.Reproduction Steps
aws-iot-device-sdk-v2
on the Nextjs app.iot
andmqtt
from'aws-iot-device-sdk-v2
andiot
andmqtt
APIs are used on the Nextjs app component.npm run dev
on terminalPossible Solution
No response
Additional Information/Context
No response
SDK version used
1.19.5
Environment details (OS name and version, etc.)
| Environment | version | | macOS | 14.4.1 | | processer | m1 chip | | node 20.12.1 | | nextjs | 13.4.7 |