journal (Mon Aug 10 2020)

Today I learnt

  • #npm
  • #vercel
  • #devops

I spent a tonne of time trying to figure out how to publish a private package on gitlab and install it both locally and on a platform like vercel. Here are some general findings.

  • Both github and gitlab have their own package registry where you can publish your private packages.
  • During build time, vercel platform or any other, would need access to the private package. This is achieved by setting an environment variable on vercel.
  • Gitlab only lets you publish scoped packages. And in order to create a scoped package, I ended up creating a group with the same name as the scope, thereby following proper naming conventions.
  • You can specify your custom registry in your .npmrc file.
  • For a consumer to install your private package, you need to create a personal access token on gitlab with api access. And use that token in the .npmrc file of your consuming app.
  • For your module itself, you need to specify the custom registry in your package.json as well as the .npmrc file so that npm publish can publish to your custom registry.
  • For integration with Vercel, you can run vc env add NPM_RC preview < ~/.npmrc. Replace preview with the other vercel environments like development and production.