Skip to content

nakamorg/rei-node-package

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@nakamorg/rei-node-package

build Actions Status publish Actions Status

This is rei (example) node package, it's companion to the Node Packages - Unit Tests and Github Actions blog issue to demonstrate using and publishing npm packages to github. But these techniques can be used for other package registries with some changes.

Install

$ npm install @nakamorg/rei-node-package

Usage

const rei = require("@nakamorg/rei-node-package");

rei();
//=> "You have succesfull installed and ran nakamorg's rei package"

Publishing your own node(npm) packages

Publishing/Testing from local

  1. Create a personal github token with following permissions: repo, write:packages
  2. Do npm login using your github username as username and personal access token as password.
    npm login --scope=@<SCOPE> --registry=https://npm.pkg.github.com 
    where SCOPE would be your github org name or username.
  3. Create a new repo for your package <package-name>. It is recommended to have same name for repo and package. Make your repo private if you want to keep your package private.
  4. Copy over all the files from here to your repo and edit files as necessary. You should, at least, update your package.json file with your package's info
  5. publish your package (CI -- GH Actions should handle publishing, but you can test as follow)
    # run tests -- we are using jest
    npm test
    # update major, minor or patch version
    npm version major
    # publish it -- should automatically be done using GH action once you push to master
    npm publish

Installing Packages

  1. Login to github packages or add corresponding entries in your .npmrc file
  2. .npmrc should include line(s) specifying github package URL(s) like:
    @nakamorg:registry=https://npm.pkg.github.com
  3. npm install @nakamorg/rei-node-package # or your package.json file

References

nvm (node version manager)

You can use nvm to install and manage multiple versions of node and npm. Install nvm using instruction from their github repo. Afterwards, installing and managing node and npm is as easy as this

nvm install 16.0.0  # Install a specific version number
nvm use 16.0        # Use the latest available 8.0.x release
nvm install node    # Install the latest available version
nvm use node        # Use the latest version

Testing Framework - Jest

jest testing framework is used for this rei (example) package. And, we encourage you to use the same for your packages and libraries.

About

Publish npm packages on Github

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published