Node.js url module vs Javascript URL

I was searching for the URL module when I found the URL on both JavaScript and Node.js.
I have a few questions:

  1. Is the JavaScript URL different from the Node.js URL?
  2. What is the difference between the URL module in Node.js and the features of JavaScript?
  3. Inside the documentation was written, the URL is known as a global object. So you no longer need to require a url module?

Browser-compatible URL class, implemented by following the WHATWG URL Standard. Examples of parsed URLs may be found in the Standard itself. The URL class is also available on the global object .

Inside the global object platform, I also saw the http , path , os , etc. modules.
I wanted to use the os and path modules without requiring (because they are inside global objects) but my file execution failed:

> node test.js
console.log(path); // ReferenceError: path is not defined

I also wrote the following code but the undefined value was printed in the output:

console.log(global.path); // undefined
  • what is the reason?

But when I use these in REPL, it returns the following output:

<ref *1> {
  resolve: [Function: resolve],
  normalize: [Function: normalize],
  isAbsolute: [Function: isAbsolute],
  join: [Function: join],
  relative: [Function: relative],
  toNamespacedPath: [Function: toNamespacedPath],
  dirname: [Function: dirname],
  basename: [Function: basename],
  extname: [Function: extname],
  format: [Function: bound _format],
  parse: [Function: parse],
  sep: '\\',
  ...
  ...
  • What is the reason for the difference between REPL and script file?

Thanks for your attention. I’m looking forward to your reply.