简体   繁体   English

node_modules分辨率详细信息

[英]node_modules resolution details

With the following lookup algorithm in mind: https://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders 请注意以下查找算法: https : //nodejs.org/api/modules.html#modules_loading_from_node_modules_folders

Say we have this in package.json: 说我们在package.json中有这个:

"dependencies":{
  "foo":"latest",
  "bar":"latest",
  "baz":"latest"
}

given the above algorithm (read the link), I believe it is absolutely true, that in our project'ss primary node_modules folder, we must have at least 3 folders: 给定以上算法(请阅读链接),我相信这是绝对正确的,在我们项目的主node_modules文件夹中,我们必须至少有3个文件夹:

node_modules/
    foo/
    bar/
    baz/

what confused me though, is that I swear I have seen case where foo/bar/baz was missing, and the modules still resolved with require. 但是让我感到困惑的是,我发誓我看到了foo / bar / baz丢失的情况,并且模块仍然可以通过require来解决。 Although maybe I was imagining things. 虽然也许我在想东西。

如果更新了packages.json文件,则大部分时间将必须运行npm install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM