Amplify-js: Can't find variable: Buffer

Created on 10 Jan 2018  路  6Comments  路  Source: aws-amplify/amplify-js

First, I had the error, "module not found stream..." so I run "npm install stream".
Then I have the error, "Can't find variable: Buffer".

If I don't import Amplify, then No error occurs.

My versions are..

node - v6.12.3
npm - v3.10.10

"dependencies": {
"aws-amplify": "^0.1.0",
"aws-amplify-react-native": "^0.1.21",
"react": "16.2.0",
"react-native": "0.52.0",
"stream": "0.0.2"
},

Of course, I tried to run this code using node version v8.9.4(LTS) but I had same error.
How can I solve this error?

import Amplify from 'aws-amplify-react-native';

export default class App extends Component<{}> {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit App.js
        </Text>
        <Text style={styles.instructions}>
          {instructions}
        </Text>
      </View>
    );
  }
}

2018-01-10 6 08 10
2018-01-10 6 09 10

Most helpful comment

Why is this issue closed?
This is a workaround and this problem is still there.
Anyway the solution @7772 shared is not working for me: npm install freezes and stops responding

All 6 comments

Oh......I solved this error.

You should follow rn-nodeify!

To sum it up..

image

image

Why is this issue closed?
This is a workaround and this problem is still there.
Anyway the solution @7772 shared is not working for me: npm install freezes and stops responding

After pulling the latest updates for aws-amplify and aws-amplify-react-native I got this error as well. I didn't try the workaround mentioned above but I did revert back to:

"aws-amplify": "^0.1.0",
"aws-amplify-react-native": "^0.1.11"

I can confirm that my app works once again after using these versions.

I tried 7772's fix yesterday and unfortunately it did not work. Downgrading to [email protected] and [email protected] didn't work either.

I get the following error:

error: bundling failed: Error: Unable to resolve module `stream` from `/Users/joshua/Documents/side-projects/RoomShakeClient/node_modules/cipher-base/index.js`: Module does not exist in the module map

react-native info output:

Environment:
  OS: macOS High Sierra 10.13.2
  Node: 8.9.1
  Yarn: 1.3.2
  npm: 5.5.1
  Watchman: Not Found
  Xcode: Xcode 9.2 Build version 9C40b
  Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
  react: 16.2.0 => 16.2.0
  react-native: 0.52.0 => 0.52.0

I'm getting Uncaught ReferenceError: Buffer is not defined when trying to compile with shadow-cljs that could be related?

   "dependencies": {
    "aws-amplify": "^0.2.14",
    "aws-sdk": "^2.224.1",
    "buffer": "^5.1.0",
    "moment": "^2.22.0"
   }

@thheller (author of shadow-cljs) helped solved the problem.

Related: https://github.com/crypto-browserify/createHash/issues/20

Had to make sure Buffer was in global namespace before requiring aws-amplify.

(ns starter.buffer-fix
  (:require ["buffer" :refer (Buffer)]))

(js/goog.exportSymbol "Buffer" Buffer)

i have the same error w/ aws-amplify 0.1 or 0.2

Was this page helpful?
0 / 5 - 0 ratings