HomeToolsAbout a20k

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, and also affect a few things about the way npm treats the package.

@somescope/somepackagename

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

@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 Use It

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
© VincentVanKoh