[英]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 npm works.这就是 npm 的工作原理。 All yours external dependencies will be downloaded to node_modules.
您所有的外部依赖项都将下载到 node_modules。
https://medium.com/maxkimambo/how-does-node-module-loading-actually-work-8aa63849f5ae#:~:text=Modules%20are%20the%20building%20block,are%20using%20ES6%20Javascript%20code.&text=included%20in%20your%20app.,can%20have%20their%20own%20package . https://medium.com/maxkimambo/how-does-node-module-loading-actually-work-8aa63849f5ae#:~:text=Modules%20are%20the%20building%20block,are%20using%20ES6%20Javascript%20code .&text=included%20in%20your%20app.,can%20have%20their%20own%20package 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.