[BUG] npm pack
completes successfully even if main
is not present in the package
#1300
Labels
Bug
thing that needs fixing
What / Why
We discovered this when one of our company's internal packages did some refactoring and moved the entry point elsewhere in the repository without remembering to update the
main
in the package.json. The end result was thatnpm pack
happily created and allowed a package that had no chance of working properly to be published.When
When
npm pack
and therefore whennpm publish
are runWhere
[email protected]
How
Current Behavior
npm pack
does not validate that themain
exists in the tarball which makes it somewhat easy to create and publish packages that cannot be used by consumers.Steps to Reproduce
npm init
and step through creating everything with default values. You'll get apackage.json
like thisnpm pack
in this directory, and observe that the tarball is happily createdThere is no
index.js
, so if this package ever attempted to be used, it would not work.Expected Behavior
npm pack
would exit with a non-zero exit code, which would also causenpm publish
to fail and prevent packages whose tarballs do not contain themain
from thepackage.json
from being published to a registry.Who
Our company ran into this when trying to publish to our internal registry.
References
The text was updated successfully, but these errors were encountered: