Be compliant with regex used by npm official registry

Problem to solve

Creating a NPM package on gitlab, when organisation has a capitalized name it's not straightforward.

Intended users

Further details

I'll talk of my experience :

npm use http://json.schemastore.org/package to validate the package name, so name should be ^(?:@[a-z0-9-~][a-z0-9-._~]*/)?[a-z0-9-~][a-z0-9-._~]*$ and have between 1 and 214 chars.

If I'm trying to create a package from repository Foo/bar, I have to use @Foo/bar as package's name, but it's breaking the regex (but it's working). If I'm trying to create a package from repository Foo/bar, and try to use @foo/bar as package's name, it's compliant with the regex, but it's not working.

What if we don't want to follow the regex ?

  • A lot of IDE will warn the invalid package name
  • npm CLI may warn npm WARN Invalid name on some npm commands

It's not blocking, but at least you can improve documentation to say "Organisation name is case sensitive", I've lost a lot of time to understood the 400 error :'(

Proposal

I think lowercased organisation name should be working in NPM registry, like an alias.

Testing

Should be retro compatible for current users who are using caps in package name

Links / references