Skip to content

Inexpressive error messages on unsupported Node.js versions #35

@willcforte

Description

@willcforte

Summary

package.json declares "engines": { "node": ">=22.0.0" }, but npm only warns
on an engines mismatch and gives an inexpressive error message of minified code followed by:

ReferenceError: crypto is not defined
    at Object.<anonymous> (/usr/local/lib/node_modules/obsidian-headless/cli.js:141:2687)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    ...
Node.js v18.19.1

Correcting your Node version will then return:

Error: libnode.so.109: cannot open shared object file: No such file or directory
  code: 'ERR_DLOPEN_FAILED'

since better-sqlite3 was compiled against the old Node version.

Environment

  • OS: Ubuntu 24.04 LTS (Noble Numbat)
  • Node.js: v18.19.1 (the default apt install nodejs version on Ubuntu 24.04)
  • obsidian-headless: 0.0.10

Steps to reproduce

# On Ubuntu 24.04 with the default apt Node 18:
sudo apt-get install -y nodejs npm
npm install -g obsidian-headless
ob login

Proposed changes

A Node version check that prints something like this would be more helpful:

obsidian-headless requires Node.js 22 or newer, but you are running Node.js <current node version>.

Upgrade Node.js (https://nodejs.org) and reinstall:
  npm install -g obsidian-headless

I also wanted to document this fix in case anyone else runs into this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions