necccc / npm-migrate

Migrate all versions of a selected package from a registry to another one
MIT License
21 stars 14 forks source link

Error {code: "ENOTDIR"} when trying to migrate packages between verdaccios #4

Open linden5 opened 5 years ago

linden5 commented 5 years ago

When trying to migrate some packages from a remote verdaccio to my local verdaccio, I get the error ENOTDIR.

user-agent: npm/6.4.1 node/v8.12.0 win32 x64

error:

code:"ENOTDIR"
__proto__:Error: ENOENT: no such file or directory, open 'C:\Users\admin\AppData\Local\Temp\npm-1892-57af5724\unpack-f25ee458\package.json'
code:"ENOENT"
errno:-4058
message:"ENOENT: no such file or directory, open 'C:\Users\admin\AppData\Local\Temp\npm-1892-57af5724\unpack-f25ee458\package.json'"
path:"C:\Users\admin\AppData\Local\Temp\npm-1892-57af5724\unpack-f25ee458\package.json"
stack:"Error: ENOENT: no such file or directory, open 'C:\Users\admin\AppData\Local\Temp\npm-1892-57af5724\unpack-f25ee458\package.json'"
syscall:"open"

The error is emitted when executing npm.commands.publish in the function publishAsync in npm_utils.js. Before the error is emitted, packages are successfully downloaded and repacked.

If I manually run npm publish /path/to/tgz --registry http://localhost:4873, everything works fine.

linden5 commented 5 years ago

After debugging into the npm 4.2.0 source code, I find that this error is emitted by npm.commands.cache.add, someone else encountered a similar problem. Publishing the directory instead of the tarball works for me.