While "requiring" non-local NodeJS modules, what is the meaning of slash in module name?
Example:
from ShellJS npm module's github page (link: )
require('shelljs/global');
require('shelljs/make');
Upon looking at the directory structure of ShellJS github project, I notice that both global.js and make.js are both at same level as shell.js which is the main entry point of the module as per its package.json. So what does the slash mean in the package name and how, in above example, is the path to "global" and "make" resolved?
While "requiring" non-local NodeJS modules, what is the meaning of slash in module name?
Example:
from ShellJS npm module's github page (link: https://github./shelljs/shelljs#javascript)
require('shelljs/global');
require('shelljs/make');
Upon looking at the directory structure of ShellJS github project, I notice that both global.js and make.js are both at same level as shell.js which is the main entry point of the module as per its package.json. So what does the slash mean in the package name and how, in above example, is the path to "global" and "make" resolved?
Share Improve this question asked Nov 10, 2015 at 2:40 codnetocodneto 2,4693 gold badges26 silver badges36 bronze badges1 Answer
Reset to default 22Slash (as it primary use), is just simply used for file paths.
require('shelljs/global')
will load script of global.js
file.
require('shelljs/make')
will load script of make.js
file.
However, require('shelljs')
will load script of shell.js
.
Why? Let's look at the content of package.json
: It's "main": "./shell.js"
that makes the magic.