amplify-js: Unable to resolve module `util` and Can't find variable: Buffer and Unable to resolve module ‘stream’
First, I had the error, “Unable to resolve module util”. So I ran npm install util which solved the problem. Then I have the error, “Can’t find variable: Buffer”.
If I don’t import Amplify, then No error occurs. It is a brand new project.
"dependencies": {
"aws-amplify": "^0.4.0",
"aws-amplify-react-native": "^0.2.11",
"react": "16.2.0",
"react-native": "0.52.0",
}
I tried “aws-amplify”: and 0.1.0 and “aws-amplify-react-native”: “^0.2.11”,
here is my react-native info:
Environment:
OS: macOS High Sierra 10.13.4
Node: 10.0.0
Yarn: 1.6.0
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.3 Build version 9E145
Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.4
I have follow this solution > https://github.com/aws/aws-amplify/issues/140 but instead with :
"devDependencies": {
...,
"rn-nodeify": "github:tradle/rn-nodeify"
}
It is worked but dependencies became a mess and also some warnings are showing on debug:
Module RCTImageLoader requires main queue setup since it overrides
initbut doesn’t implementrequiresMainQueueSetup. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
Module RNRandomBytes requires main queue setup since it overrides
constantsToExportbut doesn’t implementrequiresMainQueueSetup. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
Once I connect it to AWS, got error: Unable to resolve module ‘stream’
Thanks in advance
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 15 (4 by maintainers)
@rhishikeshj you can do a
npm i util bufferthen add this line in thelib/index.jsof the aws-amplify package:global.Buffer = global.Buffer || require('buffer').BufferYou will be able to at least launch your app for debugging untill this issue is resolved
I solved this problem!
add package.json
@vincen7su I managed to work around the “Can’t find variable: crypto” error by adding the following to the top of my
App.js. It’s a bit of a hack though… looking forward to a proper fix!I am also having issues with the CRNA and aws-amplify in a similar environment using expo. I ran the link commands but for some reason I still get an error where the util package is required in the sha.js package
The similar issue results in this error:
expo version 54.0.0
Finally Running: “npm ls sha.js”