Skip to content

Commit

Permalink
Document the supported node version in .nvmrc
Browse files Browse the repository at this point in the history
I would suggest documenting the expected node version programmatically.

The README states:

> Ensure you have the latest LTS version of Node.js installed

Currently, this [seems](https://nodejs.org/en/about/previous-releases) to be Node.js 20.

However, when I clone this repo, and I [`nvm use`](https://github.com/nvm-sh/nvm) the node version 20.16.0, and I `npm install` and I start the app with `npm run fiori`, then I get the error: 

```
❗️ ERROR on server start: ❗️

 Error: The module '/Users/me/git/cloud-cap-samples/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 108. This version of Node.js requires
NODE_MODULE_VERSION 115. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Module._extensions..node (node:internal/modules/cjs/loader:1454:18)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
    at bindings (/Users/me/git/cloud-cap-samples/node_modules/bindings/bindings.js:112:48)
    at new Database (/Users/me/git/cloud-cap-samples/node_modules/better-sqlite3/lib/database.js:48:64)
    at create (/Users/me/git/cloud-cap-samples/node_modules/@cap-js/sqlite/lib/SQLiteService.js:25:21)
    at Pool._createResource (/Users/me/git/cloud-cap-samples/node_modules/generic-pool/lib/Pool.js:319:42)
    at Pool._dispense (/Users/me/git/cloud-cap-samples/node_modules/generic-pool/lib/Pool.js:237:12)
Active connections:0
 {
  code: 'ERR_DLOPEN_FAILED'
}
```

I retried with node v18.20.4 and it worked fine. I'd suggest adding a hint about the expected node version as [a `.nvmrc` file](https://github.com/nvm-sh/nvm?tab=readme-ov-file#nvmrc) in the repo.  

Alternatively, the supported node version could be specified in the [engines](https://docs.npmjs.com/cli/v10/configuring-npm/package-json#engines) section of the package.json file.

### Version information:

```
@cap-js/asyncapi: 1.0.2
@cap-js/openapi: 1.0.4
@cap-js/sqlite: 1.7.3
@capire/samples: 2.1.0
@sap/cds: 8.0.4
@sap/cds-compiler: 5.0.6
@sap/cds-dk: 8.0.3
@sap/cds-dk (global): 8.0.3
@sap/cds-fiori: 1.2.7
@sap/cds-foss: 5.0.1
@sap/cds-mtxs: 2.0.3
@sap/eslint-plugin-cds: 3.0.4
Node.js: v20.16.0
```
  • Loading branch information
PierreFritsch authored Jul 29, 2024
1 parent a90175f commit 32c78f2
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.20

0 comments on commit 32c78f2

Please sign in to comment.