verdaccio: README published by yarn 2 is not correctly shown on verdaccio

⚠️⚠️⚠️⚠️ Workaround available, scroll down ⬇️ ⚠️⚠️⚠️⚠️

Describe the bug

README is not correctly shown on verdaccio using yarn npm publish

To Reproduce

mkdir yarn-verdaccio-readme
cd yarn-verdaccio-readme
yarn set version berry
echo '
npmPublishRegistry: http://localhost:4873
unsafeHttpWhitelist: [localhost]
' >> .yarnrc.yml
echo '
{
  "name": "yarn-verdaccio-readme",
  "version": "0.1.0"
}
' > package.json
echo '# yarn-verdaccio-readme' > README.md
yarn
docker run --rm -p 4873:4873 -d verdaccio/verdaccio:4.8.1
echo 'input some random username/password'
yarn npm login --publish
yarn npm publish
yarn npm logout --publish
echo 'open http://localhost:4873/-/web/detail/yarn-verdaccio-readme then you will see "ERROR: No README data found!".'

Expected behavior

README should be correctly shown on verdaccio

Screenshots

$ yarn npm publish
➤ YN0000: README.md
➤ YN0000: package.json
➤ YN0000: Package archive published
➤ YN0000: Done in 0.91s
image

Configuration File (cat ~/.config/verdaccio/config.yaml)

Default config in the verdaccio/verdaccio:4.8.1 docker image

Environment information

Server: the verdaccio/verdaccio:4.8.1 docker image Client: Yarn 2.1.1

Additional context

  • README.md is correctly uploaded
  • the issue seems to be that verdaccio depends on the readme field in the publish body to show the README content
  • the yarn 2 client does not provide the readme field in the publish body while npm did provide it, but the NPM registry seems to work fine without that field, for example the yarn 2 published @yarnpkg/libzip package shows the README correctly.
  • the corresponding yarn 2 issue: https://github.com/yarnpkg/berry/issues/1702

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 7
  • Comments: 16 (9 by maintainers)

Most upvoted comments

Still actual for Verdaccio v5.6.2 and Yarn v3.2.0 😕

As a temporary workaround, I ended up manually adding the readme field with the contents of the README.md. It’s suitable for the CI environment, but you can do a cleanup in the postpack script if you need to. It’s dirty enough, hope this issue will be resolved someday.

package.json

"scripts": {
  "prepack": "node scripts/prepack.js"
},

scripts/prepack.js

const path = require('path')
const fs = require('fs')
const packagePath = path.resolve('./package.json')
const readmePath = path.resolve('./README.md')
const package = require(packagePath)
const readme = fs.readFileSync(readmePath, 'utf8')
package.readme = readme
fs.writeFileSync(packagePath, JSON.stringify(package, null, 2))

I’ll ship it in the next minor release over the weekend 👍

@juanpicado Thanks for your info! The fix seems to be released at 4.9.1. (https://github.com/verdaccio/verdaccio/compare/v4.9.0...v4.9.1)

And I reported about my issue to lerna repo 😄 https://github.com/lerna/lerna/issues/2877

Nice find(s) yes I see - I’m using npm@7 (_npmVersion: '7.0.10',) 👍

Thanks for that, I’ll verify that.

What I observed: At https://github.com/verdaccio/verdaccio/blob/master/src/api/endpoint/api/publish.ts#L187 a console.log(metadataCopy) had this - Note it contains a readme: '# Test\n', for version 1.0.0

{
  _id: '@awt-lib/test',
  name: '@awt-lib/test',
  description: '',
  'dist-tags': { latest: '1.0.0' },
  versions: {
    '1.0.0': {
      name: '@awt-lib/test',
      version: '1.0.0',
      description: '',
      main: 'index.js',
      scripts: [Object],
      author: '',
      license: 'ISC',
      readme: '# Test\n',
      readmeFilename: 'README.md',
      _id: '@awt-lib/test@1.0.0',
      _nodeVersion: '15.0.0',
      _npmVersion: '7.0.10',
      dist: [Object]
    }
  },
  access: null,
  _attachments: {
    '@awt-lib/test-1.0.0.tgz': {
      content_type: 'application/octet-stream',
      data: 'H4sIAAAAAAAA/+2US0/DMAyAd+6vsIK0E3TJ+pi0Ewh64MAFOO4SWsMCa1IlGUxC+++kLyENpB2gQxP5LlZt13bi2BXPX/gTToQscBM+m9EAUErTOIbv9B0wipKUMpam1PlRRmcscnKIYnZZG8u1K+WncfqD9PJIqLr+d9K9ACV/O8ee/kdTttt/lsRT3/9D8B4AEMlLJHMg5/zNnq3Ew8SiseS0Nr2iNkLJ2spCGtJWW6DJtahsZ2mVJRfNV79KWm3raJyhTuUUTWznhvlSwYJkWis9B6mgNoCpMBePAosFgfEYcCMsMOL+3DbR+Noulf7MuRI5StMUf313SYJt8NcXemT083+bXVzdZGFZDJBj7/6ffdn/SRT7+T8EJ3Dvxs5Pjcfj8fw3PgCAjsbEAA4AAA==',
      length: 307
    }
  },
  time: {}
}

By the time it gets to https://github.com/verdaccio/verdaccio/blob/master/src/lib/local-storage.ts#L217 console.log(metadata) has readme: '',

{
  name: '@awt-lib/test',
  version: '1.0.0',
  description: '',
  main: 'index.js',
  scripts: { test: 'echo "Error: no test specified" && exit 1' },
  author: '',
  license: 'ISC',
  readme: '',
  readmeFilename: 'README.md',
  _id: '@awt-lib/test@1.0.0',
  _nodeVersion: '15.0.0',
  _npmVersion: '7.0.10',
  dist: {
    integrity: 'sha512-PqsXTkWsB6WztfEPJirFnZtWO0wCr/R/pIbUezAjYIQp1D2rNhLggVcV4AztVnduIcAzmm8Aic3c3AsIZuJ5fQ==',
    shasum: '359f0e87102e40b980f54b27722cea5e2f35352c',
    tarball: 'http://****.com/@awt-lib/test/-/@awt-lib/test-1.0.0.tgz'
  }
}

Hope this helps a bit!

Same issue on NPM (I’m running NPM version is 7.0.10)