2.1.3 • Public • Published

    How to create and publish NPM modules.

    For the time being the project scaffold expects TypeScript files.

    For a full documentation of npm usage and commands see https://docs.npmjs.com

    New project

    This describes how to create a new module from scratch. If you want to fork an existing project (recommended for new npm modules), see the step "Forking a project" further down.

    1. Create a Git repository.
    2. Clone the newly created repository to a folder on your machine.
    3. Create a folder in the project named src, all the source code will go here.
    4. Run npm init from a console window (cmd/bash etc.) in the project root and follow the steps displayed to create package.json.
    • Ensure that the package name is prefixed with @seges.
    1. Create an index.ts (TypeScript) or index.js (JavaScript) file depending on what language you wish to use.
    2. In the index file, export the modules from the src folder that you wish to expose.
    3. Run npm publish from the root of the project (double check that the project name in package.json has @seges/ as prefix, otherwise the package is published outside the seges organization scope).
    • Scoped packages are private by default, to make it public, run npm publish --access public instead.
    1. Remember to also checkin changes in Git.

    Now the module should be available for installation by running npm install <name-of-your-package> from any other project.

    Updating an existing package.

    1. Checkout the module's Git repository.
    2. Perform your needed changes.
    3. When done with your changes run npm version major|minor|patch -m <message> from the root of the project.
    1. Publish your package by running npm publish or npm publish --access public.
    2. Remember to also push changes to Git.

    The module should be updated.

    Logging in to http://www.npmjs.org you should be able to find and see the new version of the updated package.

    Unpublishing a package

    In general you should not unpublish packages as other projects might depend on them.

    Instead you should update the package with a new version containing fixes of the broken version by following the steps above.

    But in the event you need to unpublish, you can run npm unpublish <@scope/><package name>@<version> to unpublish that version.

    Note that even though a version is unpublished, a new publish of the same version is not possible unless the entire project is taken down.

    Forking a project

    The SEGES_NPM project can be used as a scaffold or base for a new npm module as it contains various necessary files required to run unit tests.

    To fork a project:

    1. Create a new git repository.
    2. Check out the SEGES_NPM project.
    3. Open a console at the root of the SEGES_NPM project.
    4. Run the command git remote set-url origin <url-of-the-project-created-in-step-1>
    5. Run the command git push origin master
    6. Rename your root project folder to the name of the repository created in step 1.


    1. Remove the project locally and checkout the repository created in step 1.

    Run through the package.json and remove comments, as they are not valid JSON.

    You should now have a new project with the contents of SEGES_NPM.


    npm i @seges/angular-localstorage

    DownloadsWeekly Downloads






    Last publish


    • jesperfriis
    • seges_bjd
    • mortenamby
    • planteit