DEV Community

Arnaldo Gabriel
Arnaldo Gabriel

Posted on

NPM Package Creation - µGuide

Note to self.

How to Publish

  1. Create an NPM account
  2. Create GitHub repo
  3. Clone repo with git clone <url>
  4. Inside the repo run: npm init
  5. Fill the required fields
  6. Push to Github: git push origin master
  7. Publish publicly: npm publish

Basic Commands

  • To publish a new version of the package: npm version 1.0.0 && npm publish
  • To see the current profile: npm profile get
  • To change a property: npm profile set <property> <value>
  • To get current local version: npm version
  • To update a specific package: npm install package@latest
  • To update if the version change is minor: npm update package

Whitelisting Specific Directories

This is useful to minimize the size of the package by not including unnecessary files present in the repo.

    {
      "name": "package-name",
      "main": "./lib/index.js",
      "files": [
        "/allowed-directory"
      ]
    }

Top comments (0)