Closed emmanuel39hanks closed 1 day ago
Windows was overlooked. All the team is working on linux and did not windows into account. I think the possible fix you mention is the way to go. We should check for on platform the cli is running and create the file in the temp folder following the OS spec (temp for lniux, and whatever it is for windows). Note: It is already working on mac and linux, just need to fix for windows
Great, will work on the fix and I will create a PR once done.
@emmanuel39hanks
A recommendation for possible fix:
NodeJS has built-in functions to let you know what a user's tmp dir is depending on their operating system. Feel free to give this doc a look and looking forward to a PR!
Description
When running the napi command on Windows, an error occurs due to a missing C:\tmp directory, where napi tries to create a session file (napi_session_id). This issue prevents napi from functioning correctly until the directory is created manually.
Error Message
Expected Behavior
The napi command should automatically create required directories or use a suitable cross-platform temporary directory such as the Windows %TEMP% environment variable, and initialize a NanoAPI project.
Actual Behavior
We get the error message
ENOENT Error on Windows - Missing C:\tmp\napi_session_id Directory
Workaround
Manually create the C:\tmp directory:
mkdir C:\tmp
Once the directory is created, napi init runs as expected.
Possible Fix
Update napi init command to automatically create the C:\tmp directory if it doesn’t exist. Alternatively, use the default OS temp directory (e.g., %TEMP% on Windows), which will avoid creating new directories on the root drive.
Steps to Reproduce
Install @nanoapi.io/napi globally on Windows:
npm install -g @nanoapi.io/napi
Run the
napi init
commandContext
This issue impacts Windows users who do not have a pre-existing C:\tmp directory, which is not created by default on the OS. Adjusting this path would make the library more cross-platform compatible.
Environment
OS: Windows 11 Node.js Version: 20.11.0 npm Version: 10.7.0