npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Can we access tarball in postpack while doing npm publish

I am trying to modify the package.json to remove un-necessary script/ devDependencies from it before publishing it as a package on npm. I am using postpack to run my script, which does this. But, I get no such file or directory error while accessing the tar file in postpack. It is also not clear in docs that postpack, when called through npm publish, will have access to the tarball or not.

npm --versions

  temp: '1.0.0',
  npm: '6.9.0',
  ares: '1.15.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.34.0',
  node: '10.15.1',
  openssl: '1.1.0j',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.2',
  v8: '',
  zlib: '1.2.11'


I have the same problem.

I wrote a postpack script to check is the tarball is complete : it creates a empty module, npm install the .tgz (which I compute using the naming conventions) and runs some basic checks with node. It works like a charm

But when invoking “npm publish” from the cli, my postpack script is invoked, but I get a ENOENT : no such file or directory for the archive.

Does anyone known where is this archive generated when publishing ?