In this shot, we will learn to create a private npm package that can be published.
If you are using npmrc, switch to an appropriate user profile. On the command line, type the following command:
npmrc <profile-name> // profile-name refers to the user profile name. Replace it with your profile name.
On the command line, type the following command to create a directory for your created package:
Navigate to your package’s root directory by typing the command below:
If you are using git to manage your package code, run the following commands:
git init git remote add origin git://git-remote-url
Remember to replace
git-remote-urlwith the git remote URL for your package.
npm init in the package root directory and pass the scope to the scope flag.
If the package is scoped within an organization, run the following command and replace
my-org with the name of your organization:
npm init --scope=@my-org
For a user-scoped package, replace
my-username with your username:
npm init --scope=@my-username
Respond to the prompts to generate a package.json file.
Although it is optional, it’s a good practice to create a
README file that explains how to use your package.
Open a text editor of your choice and write the code for your package.
View all Courses