Cli: [BUG] npm publish tarball got `ENOTDIR: not a directory` error

Created on 26 Oct 2020  ·  3Comments  ·  Source: npm/cli

Current Behavior:

With command like npm publish /path/to/tarball/from/npm-pack.tgz, npm will error with:

$ npm publish ./dr-js-core-0.4.0-dev.8.tgz
npm ERR! code ENOTDIR
npm ERR! syscall open
npm ERR! path ./dr-js-core-0.4.0-dev.8.tgz/package.json
npm ERR! errno -20
npm ERR! ENOTDIR: not a directory, open './dr-js-core-0.4.0-dev.8.tgz/package.json'

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/dr/.npm/_logs/2020-10-26T08_40_37_321Z-debug.log

And the log file:

[/home/dr/.npm/_logs/2020-10-26T08_40_37_321Z-debug.log]

0 verbose cli [
0 verbose cli   '/usr/bin/node',
0 verbose cli   '/usr/bin/npm',
0 verbose cli   'publish',
0 verbose cli   './dr-js-core-0.4.0-dev.8.tgz'
0 verbose cli ]
1 info using [email protected]
2 info using [email protected]
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:/usr/lib/node_modules/npm/npmrc Completed in 1ms
5 timing config:load:builtin Completed in 1ms
6 timing config:load:cli Completed in 2ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:/home/dr/Git/dr-js/.npmrc Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:/home/dr/.npmrc Completed in 2ms
11 timing config:load:user Completed in 2ms
12 timing config:load:file:/usr/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 3ms
16 timing config:load:setUserAgent Completed in 0ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 12ms
19 verbose npm-session 27bc3b1b0c2cde0a
20 timing npm:load Completed in 23ms
21 verbose publish [ './dr-js-core-0.4.0-dev.8.tgz' ]
22 timing command:publish Completed in 20ms
23 verbose stack Error: ENOTDIR: not a directory, open './dr-js-core-0.4.0-dev.8.tgz/package.json'
24 verbose cwd /home/dr/Git/dr-js
25 verbose Linux 5.9.1-arch1-1
26 verbose argv "/usr/bin/node" "/usr/bin/npm" "publish" "./dr-js-core-0.4.0-dev.8.tgz"
27 verbose node v15.0.1
28 verbose npm  v7.0.5
29 error code ENOTDIR
30 error syscall open
31 error path ./dr-js-core-0.4.0-dev.8.tgz/package.json
32 error errno -20
33 error ENOTDIR: not a directory, open './dr-js-core-0.4.0-dev.8.tgz/package.json'
34 verbose exit -20

Expected Behavior:

Should just publish the tarball, currently npm seem to think this is a folder to run npm pack with.

Steps To Reproduce:

Should be able to test with:
```shell script
mkdir -p ./test-npm-publish
cd ./test-npm-publish
npm init --yes
npm pack
npm publish test-npm-publish-1.0.0.tgz


### Environment:
<!--
ex.
- OS: Ubuntu 20.04
- Node: 13.14.0
- npm: 6.4.12
-->

25 verbose Linux 5.9.1-arch1-1
27 verbose node v15.0.1
28 verbose npm v7.0.5
```

Bug Release 7.x

Most helpful comment

This was something we intentionally dropped support for, but not for any strong principled reason, just that we weren't sure anyone was using it. Happy to bring support for that back, since I have some other small fixes to do in libnpmpublish anyway.

All 3 comments

The current walkaround is switch back and publish with npm@6:
```shell script
npm i -g npm@6

or use `npx` as a manual temp fix:
```shell script
npx npm@6 publish ./dr-js-core-0.4.0-dev.8.tgz --tag dev --access public

Both are tested and should work.

This was something we intentionally dropped support for, but not for any strong principled reason, just that we weren't sure anyone was using it. Happy to bring support for that back, since I have some other small fixes to do in libnpmpublish anyway.

This was fixed pretty recently, please try again in the latest release.

Was this page helpful?
0 / 5 - 0 ratings