Skip to content

snyk-labs/simple-npm-package

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

This is using the CommonJS module format for use in Node.js apps. You can read more about CommonJS vs. ESM module formats in Node.js on the LogRocket Blog

  1. Create a GitHub Repository
  2. Clone the repo locally. Example git clone https://github.com/snyk-labs/simple-npm-package.git
  3. Open your terminal and change directories to the folder of your cloned project. Example cd simple-npm-package
  4. Run npm init -y to create a package.json file. Note: if you cloned this repository you won't need to do this step.
  5. Update package.json name property with a scoped name. Example @snyk-labs/simple-npm-package. Be sure to use your username or organization name instead of mine.
  6. Write code for the package (or just use the hello world example in index.js)
  7. Sign up with npm. Also for better security be sure to enable two-factor authentication on your npm account.
  8. Sign in with your npm account in your terminal using the command npm login and follow the on-screen instructions.
  9. Run npx npm-packlist to see the contents that will be included in the published version of the package.
  10. Run npm publish --dry-run to see what would be done when actually running the command.
  11. Run npm publish --access=public to actually publish the package to npm. Note: --access=public is needed for scoped packages (@snyk-labs/simple-npm-package) as they're private by default. If it's not scoped and doesn't have the private field set to true in package.json it will be public as well.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published