Menu

My npm export worked locally. The tarball was missing the file.
📰

My npm export worked locally. The tarball was missing the file.

DEV Community: opensource·bzucker4·about 8 hours ago
#vgsD2BR3
#devtoopensource#devto#dev#package#pack
Long article (341 words) — no AI summary yet.
Reading 0:00
15s threshold

I made a test package with an export at ./settings . Node could import it from the source checkout. Then I packed the project and installed the tarball into a separate directory. The same import failed with ERR_MODULE_NOT_FOUND .

The cause was one line in package.json :

{ "exports" : { "." : "./index.cjs" , "./settings" : "./settings.mjs" } , "files" : [ "index.cjs" , "cli.cjs" ] }

Enter fullscreen mode

Exit fullscreen mode

settings.mjs existed in the checkout. The export pointed to it. The files list left it out of the tarball.

Why I built Pack Pilot

I wanted a release check that starts from the same artifact a user installs. Pack Pilot runs npm pack , installs the tarball into a temporary consumer project, and tries the public imports or CLI command I give it. The regression test uses a real npm tarball to reproduce the missing export.

For the example above, I’d add settings.mjs to files and rerun the consumer check.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.