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

@vc102375 Oh, that's bad. URL class was added in v6.13.0. The easiest way for you is switching to Node.js v8 since v6 will be EOL in less than a month. #57

Closed
attaboy opened this issue Mar 8, 2019 · 1 comment
Assignees
Labels
🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@attaboy
Copy link

attaboy commented Mar 8, 2019

@vc102375 Oh, that's bad. URL class was added in v6.13.0. The easiest way for you is switching to Node.js v8 since v6 will be EOL in less than a month.

As a quick workaround, you can add this to the very beginning of the your application:

const url = require('url'); // legacy Node6 url
const semver = require('semver');
class Node6CompatibilityURL {
  constructor(str) {
    this.url = url.parse(str);
    this.origin = this.url.protocol + '//';
    this.pathname = this.url.pathname ? this.url.pathname : '';
    this.search = this.url.search ? this.url.search : '';
    this.href = this.url.href ? this.url.href : '';
  }
}

if (semver.lt(process.version, '6.13.0')) {
  window = {};
  window.URL = Node6CompatibilityURL; // no warranty 😱 
}

Make sure you npm install semver to make it work. This code creates a global window object with window.URL that will make gaxios think it's running in browser mode, so it will use this instead of the URL class that will appear in v6.13.0. Thanks for semver check, it will keep working even after you upgrade Node.js. Please try that and let me know if it helped.

Originally posted by @alexander-fenster in #44 (comment)

@attaboy attaboy closed this as completed Mar 8, 2019
@lock
Copy link

lock bot commented Mar 15, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Mar 15, 2019
@yoshi-automation yoshi-automation added triage me I really want to be triaged. labels Apr 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants