unfoldedcircle / integration-node-library

NodeJS API wrapper for the Unfolded Circle Integration API
Apache License 2.0
0 stars 2 forks source link

Make use of nvm (Node.js version manager)? #38

Closed tinogo closed 3 weeks ago

tinogo commented 3 weeks ago

Hi, I've just seen, that the Node.js integration library requires Node.js version v16.18, but leaves it quite open on how to obtain this quite outdated Node.js version.

From my point of view, it could make sense, to add nvm (Node.js version manager) to this repository (it is a file called .nvmrc with a single line of code in it (v16.18).

The installation and usage is quite straight forward:

  1. Install nvm at first: https://github.com/nvm-sh/nvm
  2. Checkout this repository
  3. Execute nvm install or nvm use (the latter, if you already used the repo in the past)

This ensures, that every developer uses the same Node.js version, which should help prevent some bugs from using different Node.js versions. Updating to another Node.js also gets straight forward: Change the content of the .nvmrc-file to the new Node.js version, can nvm install and you are all done.

Furthermore it allows you to use the same Node.js version also in the Github-Actions (e.g. https://github.com/unfoldedcircle/integration-node-library/blob/main/.github/workflows/unit-tests.yml):

name: Run unit tests

on:
  push:
    paths:
      - '**/*.js'
      - '.github/**/*.yml'
      - 'package-lock.json'
  pull_request:
    branches: [ "main" ]
    types: [opened, synchronize, reopened]

jobs:
  test:
    name: Run tests
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup node
        uses: actions/setup-node@v4
        with:
          node-version-file: '.nvmrc'

      - name: Install dependencies
        run: npm ci

      - name: Run configured tests
        run: npm run test

WDYT?

Should I submit a pull request for that?

zehnm commented 3 weeks ago

Seems like a good idea! Especially since it's purely optional and non-invasive 👍 JS is still a strange new world to me, new things every day 😅 Please go ahead submitting a PR.

BTW: Node.js v16 is the current runtime environment on Remote 2. The next beta update should include v20.16 if we don't find any issues.

tinogo commented 3 weeks ago

Hehehe - yeah, the Node.js universe is quite...lively (and quirky)...but one gets used to it over time. 😃

I've just submitted the PR - let me know what you think of it (especially after my discovery of trying to install the NPM dependencies cleanly with npm ci with Node.js version v16.18).