Note: You can only publish unscoped packages to the npm public registry. You cannot publish unscoped packages to an npm Enterprise registry.
As an npm user, you can create unscoped packages to use in your own projects and publish them to the npm public registry for others to use in theirs. Unscoped packages are always public and are referred to by the package name only:
Create a README file that explains what your package code is and how to use it.
In your preferred text editor, write the code for your package.
Reviewing package contents for sensitive or unnecessary information
Publishing sensitive information to the registry can harm your users, compromise your development infrastructure, be expensive to fix, and put you at risk of legal action. We strongly recommend removing sensitive information, such as private keys, passwords, personally identifiable information (PII), and credit card data before publishing your package to the registry.
For less sensitive information, such as testing data, use a .npmignore or .gitignore file to prevent publishing to the registry. For more information, see this article.
Testing your package
To reduce the chances of publishing bugs, we recommend testing your package before publishing it to the npm registry. To test your package, run npm install with the full path to your package directory:
npm install my-package
Publishing unscoped public packages
On the command line, navigate to the root directory of your package.
To publish your public package to the npm registry, run:
To see your public package page, visit https://npmjs.com/package/*package-name, replacing package-name* with the name of your package. Public packages will say public below the package name on the npm website.