Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
182 views
in Technique[技术] by (71.8m points)

javascript - 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:

enter image description here

Even though I am using this files field in package.json:

"files": [
    "./dist"
  ]

Why is that?

SOLVED: It turned out that files field only works when package is published.

question from:https://stackoverflow.com/questions/65865115/why-all-files-of-my-npm-package-are-installed-in-node-modules

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Maybe you misunderstood what the files field does:

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...