You have registered and created a registry on Repsy. Now you’re ready to publish packages on it.
To create a npm package we can use npm cli’s
init command. Since Repsy only supports scoped
packages, we must include a scope name in our package name like
@foo/foo. We can do it by
--scope parameter to the command.
npm init --scope foo -y
When this command completes successfully, a package.json file will be created for us. This file is required to publish packages. You can learn more about package.json file in here.
Now we have an empty npm package. The only missing part is the authentication. In order to successfully
publish packages to our
default registry we should authenticate to it. For every different scope
we must authenticate separately. To authenticate we can use
login command, and we must provide the scope name
and the registry url to the command. For the scope
foo we can do the following.
npm login --scope foo --registry https://repo.repsy.io/npm/<username>/<registryName>
This command will ask you about your username, password and e-mail address. Use the same username and password that you used to register to the Repsy, the e-mail can be different. When this command completes we will be authenticated to the registry, and finally we are ready to publish our package. All we have to do is to tell npm to publish our package to the registry.
With this command npm will pack and publish the package to our
Congratulations you have created and published a package to the registry. Now you can install it on any project you want.