![](/img/trans.png)
[英]Node npm why all the modules are installed in the root node_modules folder?
[英]Why all files of my npm package are installed in node_modules?
這是我安裝node_modules
時在 node_modules 中的內容:
即使我在 package.json 中使用此files
字段:
"files": [
"./dist"
]
這是為什么?
也許您誤解了files
字段的作用:
可選文件字段是一個文件模式數組,描述了當 package 作為依賴項安裝時要包含的條目
當另一個項目將您的項目安裝為 npm package 時, files
字段用於定義應與您的庫一起導入的文件。
這就是模塊的工作原理。如果您不喜歡 node_modules 文件夾,請嘗試Yarn2 。 相同的東西。但不同的模塊文件夾名稱。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.