简体   繁体   English

为什么我的npm package的所有文件都安装在node_modules中?

[英]Why all files of my npm package are installed in node_modules?

Here is what I have in node_modules when I install my package:这是我安装node_modules时在 node_modules 中的内容:

在此处输入图像描述

Even though I am using this files field in package.json:即使我在 package.json 中使用此files字段

"files": [
    "./dist"
  ]

Why is that?这是为什么?

Maybe you misunderstood what the files field does:也许您误解了files字段的作用:

The optional files field is an array of file patterns that describes the entries to be included when your package is installed as a dependency 可选文件字段是一个文件模式数组,描述了当 package 作为依赖项安装时要包含的条目

The files field is used to define files that should be imported alongside your library when another project install your project as a npm package.当另一个项目将您的项目安装为 npm package 时, files字段用于定义应与您的库一起导入的文件。

Thats how module works.if you don't like node_modules folder try Yarn2 .这就是模块的工作原理。如果您不喜欢 node_modules 文件夹,请尝试Yarn2 Same thing.but different module folder name.相同的东西。但不同的模块文件夹名称。

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

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