Skip to content

Can't find variable: self #5667

@lucasfeliciano

Description

@lucasfeliciano

First I had this error after importing a internal module

TypeError: undefined is not an object (evaluating 'GLOBAL.Text={
get defaultProps(){
throw getInvalidGlobalUseError('Text');}}')

Searching for a solution I found that removing es2015 from presets on .babelrc ( which in my case I use package.json ) would fix it but then I started to get this error.

Can't find variable: self

screen shot 2016-02-01 at 16 31 38

This is the file that is throwing the exception

// the whatwg-fetch polyfill installs the fetch() function
// on the global object (window or self)
//
// Return that as the export for use in Webpack, Browserify etc.
require('whatwg-fetch');
module.exports = self.fetch.bind(self);

I could't find any information about this so I decided to open I ticket.

Here are the package.json of my react-native project:

{
  "name": "xxxx",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start"
  },
  "dependencies": {
    "client-core": "path/to/my/module/repository#myBrach",
    "immutable": "^3.7.6",
    "react-native": "^0.19.0",
    "react-native-swiper": "^1.4.3",
    "react-native-vector-icons": "^1.0.4",
    "react-redux": "^4.1.2",
    "react-timer-mixin": "^0.13.3"
  },
  "devDependencies": {
    "babel-preset-es2015": "^6.3.13",
    "babel-preset-react": "^6.3.13",
    "eslint-plugin-react": "^3.15.0"
  },
  "babel": {
    "presets": [
      "react"
    ]
  }
}

package.json of the module that I installed:

{
  "private": true,
  "version": "1.0.0",
  "description": "Client side logic core",
  "dependencies": {
    "isomorphic-fetch": "^2.2.0",
    "lodash": "^4.0.0",
    "moment": "^2.10.6",
    "nock": "^5.2.1",
    "ramda": "^0.19.0",
    "redux": "^3.0.4",
    "redux-logger": "^2.1.1",
    "redux-thunk": "^1.0.0"
  },
  "devDependencies": {
    "babel-core": "^6.3.15",
    "babel-plugin-transform-object-rest-spread": "^6.3.13",
    "babel-preset-es2015": "^6.3.13",
    "babel-preset-react": "^6.3.13",
    "chai": "^3.4.1",
    "chai-datetime": "^1.4.0",
    "deep-freeze": "0.0.1",
    "eslint": "^1.10.3",
    "eslint-plugin-mocha": "^1.1.0",
    "gulp": "^3.9.0",
    "gulp-babel": "^6.1.1",
    "gulp-babel-istanbul": "^0.11.0",
    "gulp-eslint": "^1.1.1",
    "gulp-mocha": "^2.2.0",
    "gulp-sequence": "^0.4.4",
    "isparta": "^4.0.0",
    "istanbul": "^0.4.2",
    "merge-stream": "^1.0.0",
    "mocha": "^2.3.4",
    "pre-commit": "^1.1.2",
    "sinon": "^1.17.2",
    "sinon-chai": "^2.8.0"
  },
  "scripts": {
    "test": "gulp",
    "test:watch": "mocha --compilers js:babel-core/register -w test/**/*.spec.js",
    "lint": "gulp lint"
  },
  "pre-commit": [
    "lint"
  ],
  "repository": {
    "type": "git",
    "url": "xxxxxx"
  },
  "author": "xxxx",
  "bugs": {
    "url": "xxxxxx"
  },
  "homepage": "xxxxx",
  "babel": {
    "presets": [
      "es2015",
      "react"
    ],
    "plugins": [
      "babel-plugin-transform-object-rest-spread"
    ]
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions