Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: __DEV__ is not defined when using async storage in Apollo client implementation #285

Closed
mhyousefi opened this issue Sep 19, 2017 · 1 comment

Comments

@mhyousefi
Copy link

I'm using Apollo client in my code to connect to a database and I'm using async storage somewhere in its implementation .
To import async storage, I have:

const astorage = require('react-native').asyncStorage

And then I use it as follows:

astorage.getItem('token').then((resp) => {
        if (resp) { req.options.headers['authorization'] = 'Bearer ' + resp }
        next()
})

However, I get the following error. The error goes away once don't use async storage at all. In fact, the line which requires async storage alone causes the following problem.

node_modules/.bin/mocha e2e --opts e2e/mocha.opts      
/Users/hossein/Documents/react-native-projects/myapp/node_modules/react-native/Libraries/react-native/react-native-implementation.js:17
if (__DEV__) {
    ^

ReferenceError: __DEV__ is not defined
    at Object.<anonymous> (/Users/hossein/Documents/react-native-projects/myapp/node_modules/react-native/Libraries/react-native/react-native-implementation.js:17:5)
    at Module._compile (module.js:571:32)
    at Module._extensions..js (module.js:580:10)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/hossein/Documents/react-native-projects/myapp/node_modules/babel-register/lib/node.js:152:7)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/hossein/Documents/react-native-projects/myapp/e2e/DatabaseAPIs/clientsForTest.js:2:18)
    at Module._compile (module.js:571:32)
    at loader (/Users/hossein/Documents/react-native-projects/myapp/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/hossein/Documents/react-native-projects/myapp/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/hossein/Documents/react-native-projects/myapp/e2e/DatabaseAPIs/APIs.js:4:23)
    at Module._compile (module.js:571:32)
    at loader (/Users/hossein/Documents/react-native-projects/myapp/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/hossein/Documents/react-native-projects/myapp/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at /Users/hossein/Documents/react-native-projects/myapp/node_modules/mocha/lib/mocha.js:230:27
    at Array.forEach (native)
    at Mocha.loadFiles (/Users/hossein/Documents/react-native-projects/myapp/node_modules/mocha/lib/mocha.js:227:14)
    at Mocha.run (/Users/hossein/Documents/react-native-projects/myapp/node_modules/mocha/lib/mocha.js:513:10)
    at Object.<anonymous> (/Users/hossein/Documents/react-native-projects/myapp/node_modules/mocha/bin/_mocha:480:18)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:423:7)
    at startup (bootstrap_node.js:147:9)
    at bootstrap_node.js:538:3
child_process.js:524
    throw err;
    ^

Error: Command failed: node_modules/.bin/mocha e2e --opts e2e/mocha.opts      
    at checkExecSyncError (child_process.js:481:13)
    at Object.execSync (child_process.js:521:13)
    at Object.<anonymous> (/Users/hossein/Documents/react-native-projects/myapp/node_modules/detox/local-cli/detox-test.js:46:4)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:423:7)

@mhyousefi
Copy link
Author

Sorry this issue is a duplicate of
#284
It was submitted by mistake...

@wix wix locked and limited conversation to collaborators Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants