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

Undefined is not a function. #21

Open
cezarcarvalhaes opened this issue Nov 21, 2018 · 0 comments
Open

Undefined is not a function. #21

cezarcarvalhaes opened this issue Nov 21, 2018 · 0 comments

Comments

@cezarcarvalhaes
Copy link

cezarcarvalhaes commented Nov 21, 2018

Running parseLocation inside a React app that a submodule inside a larger Gatsby project.

Getting a strange error when using parser.parseLocation(value). Browser is returning 'undefined is not a function.' Line 521 of parseaddress/address.js. Here's the full block:

    Addr_Match = {
      type    : flatten(Street_Type).sort().filter(function(v,i,arr){return arr.indexOf(v)===i }).join('|'),
      fraction : '\\d+\\/\\d+',
      state   : '\\b(?:' + keys(State_Code).concat(values(State_Code)).map(XRegExp.escape).join('|') + ')\\b',
      direct  : values(Directional).sort(function(a,b){return a.length < b.length}).reduce(function(prev,curr){return prev.concat([XRegExp.escape(curr.replace(/\w/g,'$&.')),curr])},keys(Directional)).join('|'),
      dircode : keys(Direction_Code).join("|"),
      zip     : '(?<zip>\\d{5})[- ]?(?<plus4>\\d{4})?',
      corner  : '(?:\\band\\b|\\bat\\b|&|\\@)',
    };

I suspect it's related to how XRegExp is being required at the top of the same file:

   XRegExp = __webpack_require__(/*! xregexp/src/xregexp.js */ "./node_modules/xregexp/src/xregexp.js");

Encounter a similar issue when running parser.parseAddress(value). Browser returns error: 'XRegExp.exec is not a function'. Line 682 of parseaddress/address.js:

  parser.parseAddress = function(address){
    lazyInit();
    var parts = XRegExp.exec(address,Addr_Match.address);
    return parser.normalize_address(parts);
  };

I've confirmed that xregexp is also an installed dependency.

Please advice when you get a chance, thanks!

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