Update introduction.md

Editing the specifics about this course content.

Code cannot be executed as shown , suggested edits for handling module imports described below.

@Vampeyer Do you have some context please? :slight_smile:

Update introduction.md by Vampeyer · Pull Request #2487 · exercism/javascript · GitHub which appears to be a duplicate of Update introduction.md by Vampeyer · Pull Request #2486 · exercism/javascript · GitHub

Hello there , :grinning: Yes sir , I was referring to running the code in this module as a .js file as opposed to running it as a module in a .mjs file.
( I am still learning so please, do correct me on anything at all you see where I am wrong. )

In this course , the implementation is that of using a ES6 synax module for importing and exporting JavaScript functions , variables and etc , as opposed to the require(‘’") method.

In this specific lesson there is a concern of where even the code is to be ran ,

  • Is this code running in a broswer ?
  • Is this code just running in a Node Environment ?
  • Is this meant to be - post - built code of some sort?
    — I cannot tell unto which the context it describes , as to which one to choose to even load the code.

— This is critical here , when learning modules especially , because as you may know , modern browsers do not support modern ES6 Syntax.
— While learning entirely on my own , this was a huge hurdle for me to understand and figure out , So I taught myself how to bundle packages , and properly use the modules for ES6 syntax.

Moving forward , I just tested the code locally , in a node environment , like ,
$: node index.js , and the file cannot be ran as a .js file in a node environment , as is.

In order for this code to run , as is , in a node environment , one must rename the files to .mjs , to signify to the compiler that they are indeed modules used to import and run said code.

Thats all I did to make it work , I just renamed the files and links from .js to .mjs.

The entire concept however , is a critical and crucial learning point in learning on how to properly compile node apps for websites , and use node modules in sites.

  • Because it then has to be built , and run the built code.
  • Thats the only way one can have any of the ES6 code to run in the browser ,
    ( I think so at least )
    so without teaching that or the entire component of it in a whole piece as one ,
    It can become a significantly important thing to target that , in the educational process.

That’s all.

Yes I just tested locally and it failed until I renames the files to .mjs
The example says , .js and that can be a throw off.
— Please test locally , to also check to confirm if I am correct,
or correct me where I am wrong if I am , thank you.

What’s wrong is this response here:

In a node environment, you do NOT need to rename files to .mjs in order to import them. .mjs forces a file to be a module, but there are more mechanisms to tell node to see something as a specific type of module.

Because the eco-system is still working out these kinks, no definitive change can be made to the track.

That said, we absolutely recognise the struggle one may have with commonjs modules vs es6 modules, and trying them to get to work. So do package authors. There is no consensus on what should be pushed to npm, and what transpilers should or should not take care of. There is no consensus on what default is right. We’ll get there eventually.

1 Like

65,000 people have completed this exercise, so I’m pretty sure that you don’t need to rename the files to mjs to do so. Following these instructions is all that’s required to run the tests locally: Testing on the JavaScript track | Exercism's Docs

As @SleeplessByte references, your second post on GitHub was unacceptable as a way of communicating. I’m locking this thread now. If you want to communicate further, please do so respectfully.