最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - When doing require for npm package, what is meaning of slash in package name? - Stack Overflow

programmeradmin8浏览0评论

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 badges
Add a ment  | 

1 Answer 1

Reset to default 22

Slash (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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论