Publish module js-common to NPM, and then use module.
------Open GitHubAdd project js-commongo to js-common project diradd ".gitignore" containing "node_modules"Add package.json (module entry is "index.js")push changes using git to remote repo (steps below)Push changes using git to remote repo:Open ConsoleGo to js-common project root dir# Add new Github repository named 'js-common'Accept all defaults except select "Add a README file"# Open bash or desired cli# Navigate to root of project dir
> git init
> git status
> git add *
> git status
> git commit -m "init"
# Go to Github and copy repository directory path (via "Code" button)# git remote add origin <repos path>
> git remote add origin https://github.com/gary-peterson/js-common.git
> git push -u -f origin master
# Go to Github# The default selected branch will likely be 'main'# Select the desired branch (e.g. 'master')# Test that the code is present via Code - Download ZIPMade change to code (modified index.js and package.json)
> git status
> git add *
> git status
> git commit -m "Added export for MatrixTool"
# push
> git push -u -f origin master
Repblish in NPM
> npm publish --access public
Using new libraryAdd new node.js project "js-common-remote-client"Add this to package.json:"dependencies": {"@garypeterson/js-common": "^1.0.0"},
> npm install
CodeNo changes needed, the "local client" code works:const{MinimalMatrix} = require('@garypeterson/js-common'),{Lab} = require('@garypeterson/js-common'),etc
Introduction To Node.js
(Chapter 905 - Coding Modules)