Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
url module (require)
✓ var url = require('url');
✗ import url from 'url';
CommonJS only; no ESM support. Package is not published on npm; use Component build tool.
url.parse
✓ url.parse('http://example.com')
✗ new URL('http://example.com')
Different API from Node.js url.parse; returns object with 'query' as string, not parsed.
url.isAbsolute
✓ url.isAbsolute('http://a.com')
✗ url.isAbsolute('/relative')
Returns true if URL has a scheme; false for protocol-relative '//a.com'? Check source for behavior.
Parses a URL and demonstrates all properties plus utility checks.
var url = require('url');
var parsed = url.parse('http://example.com:3000/store/shoes?sort=desc');
console.log(parsed.protocol); // 'http:'
console.log(parsed.host); // 'example.com:3000'
console.log(parsed.port); // 3000
console.log(parsed.hostname); // 'example.com'
console.log(parsed.pathname); // '/store/shoes'
console.log(parsed.search); // '?sort=desc'
console.log(parsed.query); // 'sort=desc'
console.log(parsed.hash); // ''
console.log(parsed.href); // 'http://example.com:3000/store/shoes?sort=desc'
console.log(url.isAbsolute('http://a.com')); // true
console.log(url.isRelative('/foo')); // true
console.log(url.isCrossDomain('http://other.com')); // true (if page is on different domain)
Errors
Common errors & fixes
ReferenceError: window is not defined
Running in Node.js where there is no DOM <a> element.
fixUse Node's built-in url module: const url = require('url'); url.parse('http://...'); Cannot find module 'url'
Not installed via npm; this package is for Component build system only.
fixInstall with 'component install component/url' or use a browser-ready bundler like Duo.
Uncaught TypeError: url.parse is not a function
Using the Node.js url module's parse incorrectly or importing wrong package.
fixEnsure you are using this specific package (component/url) via Component or copy source.
Audit
Dependencies
No dependency data recorded yet.