-
Notifications
You must be signed in to change notification settings - Fork 432
Description
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
Issue Title
Build Failure on macOS (Nix/Source Build): C++ compilation error in nice-napi with Clang 17
Context
This issue occurs when building @nestjs/cli from source rather than using pre-compiled binaries. This is a complete blocker for users of the Nix package manager, which enforces source-level builds to ensure reproducibility and correct linking on macOS.
Currently, the only way to get the CLI working is a workaround using npx @nestjs/cli, which bypasses the local build system.
Environment
-
OS: macOS (Darwin 24.5.0 / Sequoia)
-
Compiler: Apple Clang 17.x (latest via Xcode 16 / Command Line Tools)
-
Node Version: 20.x (LTS)
-
Package Manager: Nix (reproducible through
pkgs.nodePackages."@nestjs/cli")
Description
The compilation of the native module nice-napi (a dependency of @nestjs/cli) fails on modern macOS toolchains using Clang 17. The error is located within the node-addon-api headers.
The compiler rejects the initialization of unknown_array_type because casting -1 to an unsigned enumeration type is not a valid constant expression in modern C++ standards. While older compilers treated this as a warning, Clang 17 treats it as a fatal error.
Error Log
npm error In file included from ../binding.cc:1:
npm error .../node_modules/node-addon-api/napi.h:911:39: error: in-class initializer for static data member is not a constant expression
npm error 911 | static const napi_typedarray_type unknown_array_type = static_cast<napi_typedarray_type>(-1);
npm error | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm error .../node_modules/node-addon-api/napi.h:911:60: note: integer value -1 is outside the valid range of values [0, 15] for the enumeration type 'napi_typedarray_type'
npm error 911 | static const napi_typedarray_type unknown_array_type = static_cast<napi_typedarray_type>(-1);
npm error | ^
npm error 1 error generated.
npm error make: *** [nice_napi.target.mk:125: Release/obj.target/nice_napi/binding.o] Error 1
### Minimum reproduction code
don't have one try and install node 25 on nix and add the cli package
### Steps to reproduce
Reproducibility (Nix)
On a Mac with Nix installed, the error can be triggered via:
nix-build -E 'with import <nixpkgs> {}; nodePackages."@nestjs/cli"'
Expected behavior
should be able to use nest cli on node 25 built from source.
Package version
11.0.14
NestJS version
11.0.14
Node.js version
25
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
I understand this is a niche issue specifically affecting source-based build environments like Nix, so it may not be a high priority for the general user base. However, it is important for maintaining reproducible development environments.
I am happy to look into this further or help test potential dependency updates (specifically updating nice-napi to a version using node-addon-api v3+) if provided with some guidance on how you'd prefer to handle native dependency updates in the CLI.
Thanks for your time
Joseph