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

Cryptic error when loading a module with babel #55

Open
jcollum opened this issue Apr 12, 2017 · 3 comments
Open

Cryptic error when loading a module with babel #55

jcollum opened this issue Apr 12, 2017 · 3 comments

Comments

@jcollum
Copy link

jcollum commented Apr 12, 2017

$ cat ./src/storage.js 

export const sqrt = Math.sqrt;
export function square(x) {
    return x * x;
}
export function diag(x, y) {
    return sqrt(square(x) + square(y));
}

OK this is a pretty basic object. I'll try to import it:

~/projects/StarsApp @ Magni (jcollum) 
$ nesh -b
Babel 5.8.38 on Node v7.8.0
Type .help for more information
babel> import './src/storage';
TypeError: Cannot read property 'error' of undefined
    at OptionManager.mergeOptions (/Users/jcollum/.nvm/versions/node/v7.8.0/lib/node_modules/nesh/node_modules/babel-core/lib/transformation/file/options/option-manager.js:126:28)
    at OptionManager.addConfig (/Users/jcollum/.nvm/versions/node/v7.8.0/lib/node_modules/nesh/node_modules/babel-core/lib/transformation/file/options/option-manager.js:107:10)
    at OptionManager.findConfigs (/Users/jcollum/.nvm/versions/node/v7.8.0/lib/node_modules/nesh/node_modules/babel-core/lib/transformation/file/options/option-manager.js:168:35)
    at OptionManager.init (/Users/jcollum/.nvm/versions/node/v7.8.0/lib/node_modules/nesh/node_modules/babel-core/lib/transformation/file/options/option-manager.js:229:12)
    at compile (/Users/jcollum/.nvm/versions/node/v7.8.0/lib/node_modules/nesh/node_modules/babel-core/lib/api/register/node.js:117:22)
    at normalLoader (/Users/jcollum/.nvm/versions/node/v7.8.0/lib/node_modules/nesh/node_modules/babel-core/lib/api/register/node.js:199:14)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/jcollum/.nvm/versions/node/v7.8.0/lib/node_modules/nesh/node_modules/babel-core/lib/api/register/node.js:216:7)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)

Key line:

TypeError: Cannot read property 'error' of undefined at OptionManager.mergeOptions (/Users/jcollum/.nvm/versions/node/v7.8.0/lib/node_modules/nesh/node_modules/babel-core/lib/transformation/file/options/option-manager.js:126:28)

I'm not sure what I'm doing wrong. The error isn't much help.

@jcollum
Copy link
Author

jcollum commented Apr 26, 2017

The issue was that I had a .babelrc file in the directory (not entirely sure where it came from, I don't think react-native needs it). I renamed it and nesh -b started working.

Props to http://www.guyellisrocks.com/2015/11/babel-cannot-read-property-error-of.html

@jcollum jcollum closed this as completed Apr 26, 2017
@jcollum jcollum reopened this Apr 26, 2017
@jcollum
Copy link
Author

jcollum commented Apr 26, 2017

Ooops looks like babel is used:

  "devDependencies": {
    "babel-jest": "19.0.0",
    "babel-preset-react-native": "1.9.1",
    "jest": "19.0.2",
    "react-test-renderer": "16.0.0-alpha.6"
  },

Nesh uses babel 5.8, when will it be upgraded to 6? That might solve this issue.

$ nesh -b
Babel 5.8.38 on Node v7.9.0

@jcollum
Copy link
Author

jcollum commented Jul 31, 2018

Hey I just ran into this one again, any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant