Does npm publish the npm package

Given the Node.js package manager, namely npm , was I curious if the publishing team runs the pack command before publishing, or if it does something different at all? Therefore, if I were to execute:

npm publish <folder> 

Does this primarily do the following:

 npm pack <folder> 

I could not find anything mentioned in the documentation .


The main reason I'm curious is because our build process just does npm publish without an explicit npm pack earlier, but the package does not have the expected content. those..; .tgz content is different when I run local npm pack with npm publish content.
+8
npm npm-publish
source share
1 answer

Looking at the source of NPM, you will see that it comes to the publishFromDirectory function and calls it in the pack module.

https://github.com/npm/npm/blob/b80d650def417645d2525863e9f17af57a917b42/lib/publish.js#L79 and again at https://github.com/npm/npm/blob/b80d650def417645d2525817ebblfbaflfbaf

If you go through the package module, you will see that the _pack function performs the same 2 steps:

https://github.com/npm/npm/blob/114d518c75732c42acbef3acab36ba1d0fd724e2/lib/pack.js#L67

So, to answer your question, it does not do exactly pack <folder> , but calls the same basic code paths.

The code is mostly well written and not difficult to follow, I would advise you to delve into the source code of these projects for this type of question, since your knowledge of the tools you use will explode if you do this.

+1
source share