HomeToolsAbout

Scope

What Is It

All npm packages have a name.

  • Some package names also have a scope.

Scopes are a way of grouping related packages together.

@somescope/somepackagename import "@somescope/somepackagename"

In broader scope of npm publishing, @scope should be a name of a user or an organization.

  • Each npm user/organization has their own scope, and only you can add packages in your scope.
@username/module
@org/module

You HAVE to name the scope with @ prefixed if it is an npm package.

  • It is easy to get a regular file path or tsconfig alias mixed with npm scope if not prefixed with @

How to create scoped packages

List the named scopes in NPM

npm list

Initialize Scoped package

# in the package root directory npm init --scope=@scope_name

If you want to privately publish a package, you need a npm Private Module account

npm publish --access restricted

For publishing publicly

npm publish --access public
AboutContact