1.0.2 • Published 6 years ago

fe-shared-components-2 v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

Create and update your npm-package

Preparation

  1. You'll need a npm-account.
  2. You'll need a git-account.
  3. npm and git must to be installed on your system.

Create a package

Start your package by using npm init. This will guide you through a quick process. Watch out for these fields:

  • name (required) must be globally unique! To ensure this, its common sense to use namespaces, eg. project-name-package-name.
  • version (required).
  • main (required) starting point, index.js by default.
  • author (optional) format: Your Name <your@email.com> (https://your-website.de)

Next, create a file named like your main-field above (index.js by default). Your code inside must be exported, otherwise you cant use it when including your package. Your file may look like this:

exports.printMyMessage() = function() {
    console.log('Hello World');
}

Create a Readme.md file. This will be used as your default readme for both git and npm.

Your folder structure should now look like this:

  • package-folder
    • package.json
    • index.js
    • Readme.md

At this point you should start your git-repository. Use git init and push to the repository-provider of your choice. Make sure your working directory is clean!

Notice: Like git, everything in your package-folder will be included in your package! You can use a .npmignore-file to exclude certain files or folders as you do with .gitignore.

Login to your npm-account via npm login. Fill in your credentials.

Finally, publish your package by using npm publish.

Done!

Your package is now aviable in your profile (for official npm, this will be https://npmjs.org/~your.username) or directly via https://npmjs.com/packge/your-package-name.

Update your npm-package

  1. Change or add files as you need.
  2. Push your changes to git. Your working directory must be clean!
  3. Update your package-version by using npm version patch. This will increase your version like 1.0.0 to 1.0.1.
  4. Publish updated package using npm publish.
1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago