Repository: promptfoo/promptfoo
Issue: promptfoo view error
Root cause: Environment Incompatibility

**Describe the bug**
Not able to run `promptfoo view`, always get the following error. Has tried delete npm_moudles and install again.
LLM-RGB git:(main) ✗ promptfoo view
(node:43616) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

=======================================================================================================================================================================================
⚠️ The current version of promptfoo 0.91.3 is lower than the latest available version 0.102.4.

Please run npx promptfoo@latest or npm install -g promptfoo@latest to update.
=======================================================================================================================================================================================

Error running database migrations: The module '/opt/homebrew/lib/node_modules/promptfoo/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 127. This version of Node.js requires
NODE_MODULE_VERSION 131. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
Error running database migrations: The module '/opt/homebrew/lib/node_modules/promptfoo/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 127. This version of Node.js requires
NODE_MODULE_VERSION 131. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
Migrated results from file system to database
Server running at http://localhost:15500 and monitoring for new evals.
Open URL in browser? (y/N): node:internal/modules/cjs/loader:1724
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: The module '/opt/homebrew/lib/node_modules/promptfoo/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 127. This version of Node.js requires
NODE_MODULE_VERSION 131. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object..node (node:internal/modules/cjs/loader:1724:18)
    at Module.load (node:internal/modules/cjs/loader:1303:32)
    at Function._load (node:internal/modules/cjs/loader:1117:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:218:24)
    at Module.require (node:internal/modules/cjs/loader:1325:12)
    at require (node:internal/modules/helpers:136:16)
    at bindings (/opt/homebrew/lib/node_modules/promptfoo/node_modules/bindings/bindings.js:112:48)
    at new Database (/opt/homebrew/lib/node_modules/promptfoo/node_modules/better-sqlite3/lib/database.js:48:64)
    at getDb (/opt/homebrew/lib/node_modules/promptfoo/dist/src/database/index.js:45:24) {
  code: 'ERR_DLOPEN_FAILED'
}

**To Reproduce**
execute `promptfoo view`

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**System information:**
MacOS 15.1.1
Node.js v23.3.0

If possible, please output the results of `promptfoo debug` and paste the output here.

- Promptfoo version:

**Additional context**
Add any other context about the problem here.


Hi @zhlmmc, it looks like your system is referencing an older `promptfoo` installation, and you may have upgraded your Node version since installing that older version. Here are some steps to troubleshoot:

1. Run `which promptfoo` to see where `promptfoo` is installed. You can try uninstalling it with `npm uninstall -g promptfoo`, `brew uninstall promptfoo`, or `rm $(which promptfoo)`. You may need to do this multiple times if you have multiple installations. Repeat until `which promptfoo` returns no results.
2. Try running `npx promptfoo@latest --version`.
3. Reinstall using `npm install -g promptfoo@latest`, or run `npx promptfoo@latest` without installing. You can also pick another installation method from [the docs](https://www.promptfoo.dev/docs/installation/).
4. Confirm the correct version by running `promptfoo --version`. As of now, the latest version is `0.102.4`.
5. If none of the above works, use `nvm` to run Promptfoo with Node 22 (`nvm use 22`), then install Promptfoo again.

Good luck and let me know how it goes!

yes, it works. Thanks!