Skip to main content
Regexflux

npm Package Name

intermediate

Matches valid npm package names including scoped packages.

npmpackagenodedevelopment

Pattern

/(?:@[a-z0-9-~][a-z0-9-._~]*/)?[a-z0-9-~][a-z0-9-._~]*/g

Try It

0 of 7 strings matched

Explanation

Matches npm package names: optional scope (@org/) followed by a lowercase name. Names can contain lowercase letters, digits, hyphens, dots, underscores, and tildes.

Test Strings

Matching

  • react
  • @types/node
  • lodash
  • @my-org/my-package

Non-matching

  • !!!

Language Compatibility

LanguageSupport
JSFull support
PYTHONFull support
JAVAFull support
PHPFull support
GOFull support

Code Snippets

const regex = /(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);

Related Patterns