1

From today verdaccio (v3.8.3) stopped showing packages in local registry.

Opening on browser this message is shown: No Package Published Yet

The storage folder specified in configuration (~/.local/share/verdaccio/storage) contains all my packages.

But database file is empty ~/.local/share/verdaccio/storage/.sinopia-db.json. Indeed running verdaccio from terminal I get this:

 warn --- config file  - /home/bssadmin/.config/verdaccio/config.yaml
 error--- Package database file corrupted (invalid JSON), please check the error printed below.
File Path: /home/bssadmin/.local/share/verdaccio/storage/.sinopia-db.json SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at LocalDatabase._parseDatabase (/home/bssadmin/.npm-packages/lib/node_modules/verdaccio/node_modules/@verdaccio/local-storage/lib/local-database.js:298:19)
    at LocalDatabase._fetchLocalPackages (/home/bssadmin/.npm-packages/lib/node_modules/verdaccio/node_modules/@verdaccio/local-storage/lib/local-database.js:272:23)
    at new LocalDatabase (/home/bssadmin/.npm-packages/lib/node_modules/verdaccio/node_modules/@verdaccio/local-storage/lib/local-database.js:49:22)
    at LocalStorage._loadStorage (/home/bssadmin/.npm-packages/lib/node_modules/verdaccio/build/lib/local-storage.js:809:14)
    at new LocalStorage (/home/bssadmin/.npm-packages/lib/node_modules/verdaccio/build/lib/local-storage.js:54:27)
    at Storage.init (/home/bssadmin/.npm-packages/lib/node_modules/verdaccio/build/lib/storage.js:64:25)
    at /home/bssadmin/.npm-packages/lib/node_modules/verdaccio/build/api/index.js:145:19
    at Generator.next (<anonymous>)
    at step (/home/bssadmin/.npm-packages/lib/node_modules/verdaccio/build/api/index.js:53:191)
 error--- Database is locked, please check error message printed during startup to prevent data loss.
(node:9242) ExperimentalWarning: The fs.promises API is experimental
 error--- Database is locked, please check error message printed during startup to prevent data loss.
 warn --- Plugin successfully loaded: htpasswd
 warn --- Plugin successfully loaded: audit
 warn --- http address - http://0.0.0.0:4873/ - verdaccio/3.8.3

What's happened? How can I resolve?

I should tag this question with 'verdaccio' tag but is not available and I can't create it.

gyc
  • 4,300
  • 5
  • 32
  • 54
assistbss
  • 527
  • 7
  • 25

1 Answers1

1

If the .sinopia-db.json. is empty, pretty likely was corrupted. If there were any private packages you might need to fix it manually.

The format is pretty simple

{"list":["@test/test_1","@test/test_2","@test/test_3","test_4"],"secret":"secretKEYLongString"}

This file must be a valid JSON format.

If in the other had, the database was empty, just let the list array empty, or remove the whole file, restart the server and Verdaccio will generate a new one.

Juan Picado
  • 1,823
  • 18
  • 33
  • I have a hudge database that I have not backup since 3 months and this file is empty. What are my best chances? Is the `secret` important? I can't guess this one. Can I leave it empty? – Dimitri Kopriwa Jun 10 '20 at 17:36
  • `secret` is important, is the one that actually is the salt for the passwords, if you lose that one or change it all the tokens will be invalidated. – Juan Picado Jun 10 '20 at 19:56
  • Ok. So it is not the worst tong in the world to loose it. What about the rest of the files, what happen if the closest backup is 3 month old and about 50 releases happened and 10 was newly created packages ? – Dimitri Kopriwa Jun 10 '20 at 22:45
  • Well, the question was regarding the db file, but if you organize your private packages by storage (https://verdaccio.org/docs/en/packages#configuration) you might backup only your private packages, I guess you do not want to backup the whole npmjs. – Juan Picado Jun 11 '20 at 04:56