The Be Sure Blog

Code Snippets | Problem Solving | Tips & Tricks

The Be Sure Blog banner

CI/CD: How I finally fixed "err: npm WARN EBADENGINE"

posted on 11.4.2023 by Below Surface in "GitHub"

When setting up a GitHub action, my goal was to run a .sh script on my Ubuntu server. The script worked fine when triggering it manually with

bash myscript.sh

However, when running it with a GitHub action script like this:

on:
  push:
    branches:
      - main
jobs:
  update_ssh_linode:
    name: Telling server to update
    runs-on: ubuntu-latest
    steps:
    - name: executing remote ssh commands using password
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.SERVER_HOST }}
        username: ${{ secrets.SERVER_USERNAME }}
        password: ${{ secrets.SERVER_PASSWORD }}
        port: ${{ secrets.PORT }}
        script: bash myscript.sh

I would get these errors in GitHub:

err: npm WARN EBADENGINE Unsupported engine {
err: npm WARN EBADENGINE   package: '@npmcli/fs@3.1.0',
err: npm WARN EBADENGINE   required: { node: '^14.17.0 || ^16.13.0 || >=18.0.0' },
err: npm WARN EBADENGINE   current: { node: 'v12.***.9', npm: '8.5.1' }
err: npm WARN EBADENGINE }
err: npm WARN EBADENGINE Unsupported engine {
err: npm WARN EBADENGINE   package: '@npmcli/git@4.0.3',
err: npm WARN EBADENGINE   required: { node: '^14.17.0 || ^16.13.0 || >=18.0.0' },
err: npm WARN EBADENGINE   current: { node: 'v12.***.9', npm: '8.5.1' }
err: npm WARN EBADENGINE }
err: npm WARN EBADENGINE Unsupported engine {
err: npm WARN EBADENGINE   package: 'which@3.0.0',
err: npm WARN EBADENGINE   required: { node: '^14.17.0 || ^16.13.0 || >=18.0.0' },
err: npm WARN EBADENGINE   current: { node: 'v12.***.9', npm: '8.5.1' }
err: npm WARN EBADENGINE }


I wondered how that would be possible, since the server used Node.js v18.12.1. The solution that took me too long to find was to add these lines to the top of my .sh script, to make sure the script would execute its commands by using Node version 18.12.1:

source ~/.nvm/nvm.sh
nvm use 18.12.1

The first line is necessary to use NVM in this script.

Tags:

github
github actions
node.js
bash script
.sh
ebadengine
unsupported engine
ci/cd

Sources:

https://stackoverflow.com/questions/16904658/node-version-manager-install-nvm-command-not-found

More posts of this category

Get started with GitHub Actions

Learn about CI/CD with GitHub

GitHub

Git Merge VS Rebase, pros and cons for each

Learn more about git merge and git rebase and their differences

GitHub

Fixing .gitignore is ignoring a .gitignore rule

Ignoring a folder does not work? This may be a solution!

GitHub

Delete files and folders from GitHub history

How I deleted a folder from the GitHub history of a repository

GitHub