0.0.2 • Published 3 years ago
@clarkio/simple-npm-package v0.0.2
Simple npm Package
A simple npm package for demonstration purposes and use in a Node.js app.
Get Started
Follow these steps to publish your own npm package for your own project or using this project.
- Create a GitHub Repository
- Clone the repo locally. Example
git clone https://github.com/clarkio/simple-npm-package.git - Open your terminal and change directories to the folder of your cloned project. Example
cd simple-npm-package - Run
npm init -yto create apackage.jsonfile. Note: if you cloned this repository you won't need to do this step. - Update package.json name property with a scoped name. Example
@clarkio/simple-npm-package. Be sure to use your username or organization name instead of mine. - Write code for the package (or just use the hello world example in
index.js) - Sign up with npm. Also for better security be sure to enable two-factor authentication on your npm account.
- Sign in with your npm account in your terminal using the command
npm loginand follow the on-screen instructions. - Run
npx npm-packlistto see the contents that will be included in the published version of the package. - Run
npm publish --dry-runto see what would be done when actually running the command. - Run
npm publish --access=publicto actually publish the package to npm. Note: --access=public is needed for scoped packages (@clarkio/simple-npm-package) as they're private by default. If it's not scoped and doesn't have theprivatefield set totrueinpackage.jsonit will be public as well.