Question about modules


#1

First question on these forums, I apologize if it’s not formatted correctly.

In the video for exercise 07 Zed states that const readline = require(“readline-sync”); basically tells node to look for a folder named “readline-sync” in our node_module folder. We installed the readline sync folder using npm and I can see that the folder is there.

In exercise 09 we use const fs = require(“fs”) however we never install this into our node_module folder. My question is how does node know how to find this folder? I’m assuming it has something to do with relative vs absolute paths however I’m not sure.


#2

fs comes already installed in Node core.
There are some modules you need to install because they are not part of the core. These extras are stored in the node_modules folder.


#3

What IO says is true for nearly all languages. They have a core set of libraries, but many people create new libraries to extend the language.

Different languages have different ways to ‘import’ the extended features.