When doing require for npm package, what is meaning of slash in package name?

前端 未结 1 1887
伪装坚强ぢ
伪装坚强ぢ 2021-02-18 13:11

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.com

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-18 13:49

    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 讨论(0)
提交回复
热议问题