garycourt/uri-js

undefined is not an object (evaluating 'URI.SCHEMES')

Closed this issue · 5 comments

Using as a dependency of oauth-signature, Line 4 /build/schemes/http.js":

URI.SCHEMES["http"] = URI.SCHEMES["https"] = is throwing this error.

@mixophrygian If you're using react-native and seeing this error (we were), it looks related to how it's requiring things.
We're still debugging to figure it out...
Try this out:

OLD:
///<reference path="../uri.ts"/> if (typeof COMPILED === "undefined" && typeof URI === "undefined" && typeof require === "function") var URI = require("../uri");

NEW:

var URI = require("../uri"); ///<reference path="../uri.ts"/> if (typeof COMPILED === "undefined" && typeof URI === "undefined" && typeof require === "function")

We did this in a couple places and it started to work, looking for a lasting solution now though

Yes, I am having this problem in react-native, version 0.27.2 and oauth-signature version 1.3.1. Unfortunately that fix didn't resolve the issue for me.

retro commented

This also failing with ClojureScript compiler. It seems that COMPILED is not undefined, it's a boolean

Welp, if you initialize URI.SCHEMES as an empty object before the http or https attributes get set, it works.

Add URI.SCHEMES = {}; to line four.

Version 3 of URI.js has been refactored and should fix this issue.