ECDMA stupidity

Suppose we have SDU as follows:
/ is root of project
js holds JS staff.

Inside js we create tomodule.js and romodule.mjs

tomodule.js

console.log('Arr: ');

Above script:

  • asserts that console maps system’s default stdout
  • prints out message in system’s default charcode ( no charcode specified )

Because of node stupidity, we cannot just:

require ('tomodule.js');

inside romodule.mjs
!!! HELP !!!

Well you’ve told Node that romodule is an actual spec-compliant JS module, then you’ve tried to use it as a CommonJS module. The solution would be to not instruct Node that romodule is an ESModule by using the correct extension

Renaming extension from mjs to js didnt solve it.
Uaing node sucks at its fullest.

Unable to use freaking commonjs modules inside classic js
If so, than what was the point of introducing commonjs?

Is what you posted above the entirety of your code? If it is, then you aren’t exporting anything at all so everything in each module is private. If it is not the entirety of your code then it’s a little difficult to provide help as we can’t see what you can see on your screen.

JS didn’t have module system, it didn’t exist.

Node needed a module system, so the designers of Node wrote one.

Alternative to CommonJS was no modules at all, which wouldn’t have been at all practical.

why do you say what I quoted?

I didn’t?? The alternative to having the module system Node has was not having modules. JavaScript did not have any form of standarised module system, there was literally no choice but to create one.

You asked what the point was of introducing CommonJS modules. The point was that they needed modules, if they didn’t create a module system then they wouldn’t have had modules.

Again, though, it’s extremely hard to see exactly what you’re doing wrong here without any code.