0

I want to publish my library first time on NPM.
I want it to be public. So in the package.json file of my library I have

"name": "firstname-lastname/testlib123"

so my first name - my last name/ my library name in my case it is testlib123

and I get error:

Invalid name when I try to publish.

Also in VS code i have this warning:

String does not match the pattern of "^(?:@[a-z0-9-*~][a-z0-9-*._~]*/)?[a-z0-9-~][a-z0-9-._~]*$".

I don't understand regex. Where is my mistake ?

vsync
  • 87,559
  • 45
  • 247
  • 317
Petar
  • 35
  • 5

1 Answers1

0

As I've said in the comment, follow this guide:

  1. Create (if not already done) a user on NPM website
  2. Your package name should start with @ and then your username which you have signed up to NPM with and then the package name, example: @petar/my-package
  3. The first publish should be using this command: npm publish --access public and all later published can simply be done with the npm publish command.

I have written an article regarding automating private NPM packages releases which I think you should read if you wish to write open-source NPM packages without much hassle when publishing.


Regarding your regex, are you sure you pasted it here correctly? I've had to remove one character in order to have it parsed, and here's a website which explains regexes:

enter image description here

vsync
  • 87,559
  • 45
  • 247
  • 317