bug: Leftover dot-prefixed temp directory in global node_modules breaks npm -g update on Windows #3030

Open
opened 2026-02-16 17:38:18 -05:00 by yindo · 7 comments
Owner

Originally created by @SHJordan on GitHub (Nov 21, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

The opencode-ai package appears to be creating a temporary directory (e.g., .opencode-ai-r3F0EMZ1) directly inside the global node_modules folder on Windows.

If this directory is not cleaned up, it causes all future global npm updates to fail with EINVALIDPACKAGENAME, as npm attempts to parse the dot-prefixed directory as a package.

Observed Error:

npm error code EINVALIDPACKAGENAME
npm error Invalid package name ".opencode-ai-r3F0EMZ1" of package ".opencode-ai-r3F0EMZ1@*": name cannot start with a period.

Root Cause Analysis

It seems the package (likely the postinstall script or the binary downloader) uses node_modules as a scratchpad for temporary extraction but fails to clean it up or ignore it. Since npm strictly validates folder names in node_modules during updates, this leftover artifact blocks standard npm maintenance commands.

Workaround:

Manually deleting the .opencode-ai-* directory restores npm functionality.

OpenCode version

1.0.85

Steps to reproduce

  1. Install opencode-ai globally on Windows (npm i -g opencode-ai).
  2. (Trigger condition unclear, possibly during install or first run).
  3. Observe a directory like .opencode-ai-xxxxxx in %APPDATA%\npm\node_modules.
  4. Run npm -g update.

Screenshot and/or share link

Image

Operating System

Windows 11

Terminal

Warp + pwsh 7

Originally created by @SHJordan on GitHub (Nov 21, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description The opencode-ai package appears to be creating a temporary directory (e.g., .opencode-ai-r3F0EMZ1) directly inside the global node_modules folder on Windows. If this directory is not cleaned up, it causes all future global npm updates to fail with EINVALIDPACKAGENAME, as npm attempts to parse the dot-prefixed directory as a package. ## Observed Error: > npm error code EINVALIDPACKAGENAME > npm error Invalid package name ".opencode-ai-r3F0EMZ1" of package ".opencode-ai-r3F0EMZ1@*": name cannot start with a period. ## Root Cause Analysis It seems the package (likely the postinstall script or the binary downloader) uses node_modules as a scratchpad for temporary extraction but fails to clean it up or ignore it. Since npm strictly validates folder names in node_modules during updates, this leftover artifact blocks standard npm maintenance commands. ## Workaround: Manually deleting the .opencode-ai-* directory restores npm functionality. ### OpenCode version 1.0.85 ### Steps to reproduce 1. Install opencode-ai globally on Windows (npm i -g opencode-ai). 2. (Trigger condition unclear, possibly during install or first run). 3. Observe a directory like .opencode-ai-xxxxxx in %APPDATA%\npm\node_modules. 4. Run npm -g update. ### Screenshot and/or share link <img width="1105" height="70" alt="Image" src="https://github.com/user-attachments/assets/80f025de-3d59-4425-98b8-26d431ff7086" /> ### Operating System Windows 11 ### Terminal Warp + pwsh 7
yindo added the bug label 2026-02-16 17:38:18 -05:00
Author
Owner

@SHJordan commented on GitHub (Nov 21, 2025):

complete log

0 verbose cli C:\tools\nodejs\node.exe C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
1 info using npm@11.6.2
2 info using node@v25.2.1
3 silly config load:file:C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\npmrc
4 silly config load:file:C:\Users\iopdev.npmrc
5 silly config load:file:C:\Users\iopdev\AppData\Roaming\npm\etc\npmrc
6 verbose title npm update
7 verbose argv "--global" "update"
8 verbose logfile logs-max:10 dir:C:\Users\iopdev\AppData\Local\npm-cache_logs\2025-11-21T14_18_40_975Z-
9 verbose logfile C:\Users\iopdev\AppData\Local\npm-cache_logs\2025-11-21T14_18_40_975Z-debug-0.log
10 silly packumentCache heap:4496293888 maxSize:1124073472 maxEntrySize:562036736
11 silly logfile start cleaning logs, removing 1 files
12 silly logfile done cleaning log files
13 silly idealTree buildDeps
14 verbose stack Error: Invalid package name ".opencode-ai-r3F0EMZ1" of package ".opencode-ai-r3F0EMZ1@": name cannot start with a period.
14 verbose stack at invalidPackageName (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules\npm-package-arg\lib\npa.js:136:15)
14 verbose stack at Result.setName (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules\npm-package-arg\lib\npa.js:184:13)
14 verbose stack at new Result (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules\npm-package-arg\lib\npa.js:172:12)
14 verbose stack at npa.resolve (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules\npm-package-arg\lib\npa.js:82:15)
14 verbose stack at #nodeFromEdge (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\build-ideal-tree.js:1064:22)
14 verbose stack at #buildDepStep (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\build-ideal-tree.js:929:35)
14 verbose stack at #buildDeps (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\build-ideal-tree.js:781:30)
14 verbose stack at Arborist.buildIdealTree (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\build-ideal-tree.js:182:28)
14 verbose stack at async Arborist.reify (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\reify.js:114:5)
14 verbose stack at async Update.exec (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\lib\commands\update.js:64:5)
15 error code EINVALIDPACKAGENAME
16 error Invalid package name ".opencode-ai-r3F0EMZ1" of package ".opencode-ai-r3F0EMZ1@
": name cannot start with a period.
17 silly unfinished npm timer reify 1763734730278
18 silly unfinished npm timer reify:loadTrees 1763734730311
19 silly unfinished npm timer idealTree:buildDeps 1763734730321
20 silly unfinished npm timer idealTree:#root 1763734730322
21 verbose cwd C:\Users\iopdev\code\gerador_antigo_funcional
22 verbose os Windows_NT 10.0.26100
23 verbose node v25.2.1
24 verbose npm v11.6.2
25 verbose exit 1
26 verbose code 1
27 error A complete log of this run can be found in: C:\Users\iopdev\AppData\Local\npm-cache_logs\2025-11-21T14_18_40_975Z-debug-0.log

@SHJordan commented on GitHub (Nov 21, 2025): <details><summary>complete log</summary> <p> 0 verbose cli C:\tools\nodejs\node.exe C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js 1 info using npm@11.6.2 2 info using node@v25.2.1 3 silly config load:file:C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\npmrc 4 silly config load:file:C:\Users\iopdev\.npmrc 5 silly config load:file:C:\Users\iopdev\AppData\Roaming\npm\etc\npmrc 6 verbose title npm update 7 verbose argv "--global" "update" 8 verbose logfile logs-max:10 dir:C:\Users\iopdev\AppData\Local\npm-cache\_logs\2025-11-21T14_18_40_975Z- 9 verbose logfile C:\Users\iopdev\AppData\Local\npm-cache\_logs\2025-11-21T14_18_40_975Z-debug-0.log 10 silly packumentCache heap:4496293888 maxSize:1124073472 maxEntrySize:562036736 11 silly logfile start cleaning logs, removing 1 files 12 silly logfile done cleaning log files 13 silly idealTree buildDeps 14 verbose stack Error: Invalid package name ".opencode-ai-r3F0EMZ1" of package ".opencode-ai-r3F0EMZ1@*": name cannot start with a period. 14 verbose stack at invalidPackageName (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules\npm-package-arg\lib\npa.js:136:15) 14 verbose stack at Result.setName (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules\npm-package-arg\lib\npa.js:184:13) 14 verbose stack at new Result (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules\npm-package-arg\lib\npa.js:172:12) 14 verbose stack at npa.resolve (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules\npm-package-arg\lib\npa.js:82:15) 14 verbose stack at #nodeFromEdge (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1064:22) 14 verbose stack at #buildDepStep (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:929:35) 14 verbose stack at #buildDeps (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:781:30) 14 verbose stack at Arborist.buildIdealTree (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:182:28) 14 verbose stack at async Arborist.reify (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:114:5) 14 verbose stack at async Update.exec (C:\Users\iopdev\AppData\Roaming\npm\node_modules\npm\lib\commands\update.js:64:5) 15 error code EINVALIDPACKAGENAME 16 error Invalid package name ".opencode-ai-r3F0EMZ1" of package ".opencode-ai-r3F0EMZ1@*": name cannot start with a period. 17 silly unfinished npm timer reify 1763734730278 18 silly unfinished npm timer reify:loadTrees 1763734730311 19 silly unfinished npm timer idealTree:buildDeps 1763734730321 20 silly unfinished npm timer idealTree:#root 1763734730322 21 verbose cwd C:\Users\iopdev\code\gerador_antigo_funcional 22 verbose os Windows_NT 10.0.26100 23 verbose node v25.2.1 24 verbose npm v11.6.2 25 verbose exit 1 26 verbose code 1 27 error A complete log of this run can be found in: C:\Users\iopdev\AppData\Local\npm-cache\_logs\2025-11-21T14_18_40_975Z-debug-0.log </p> </details>
Author
Owner

@rekram1-node commented on GitHub (Nov 21, 2025):

Ill fix it, but let's see if the bot can help

@rekram1-node commented on GitHub (Nov 21, 2025): Ill fix it, but let's see if the bot can help
Author
Owner

@rekram1-node commented on GitHub (Nov 21, 2025):

/oc find out what is causing this issue and then fix it please. Double check your work, follow best practices, avoid being verbose

@rekram1-node commented on GitHub (Nov 21, 2025): /oc find out what is causing this issue and then fix it please. Double check your work, follow best practices, avoid being verbose
Author
Owner

@opencode-agent[bot] commented on GitHub (Nov 21, 2025):

Created PR #4602

New%20session%20-%202025-11-21T18%3A29%3A51.128Z
opencode session  |  github run

@opencode-agent[bot] commented on GitHub (Nov 21, 2025): Created PR #4602 <a href="https://opencode.ai/s/wgYRIqEv"><img width="200" alt="New%20session%20-%202025-11-21T18%3A29%3A51.128Z" src="https://social-cards.sst.dev/opencode-share/TmV3IHNlc3Npb24gLSAyMDI1LTExLTIxVDE4OjI5OjUxLjEyOFo=.png?model=opencode/glm-4.6&version=1.0.85&id=wgYRIqEv" /></a> [opencode session](https://opencode.ai/s/wgYRIqEv)&nbsp;&nbsp;|&nbsp;&nbsp;[github run](/sst/opencode/actions/runs/19579893263)
Author
Owner

@SHJordan commented on GitHub (Nov 21, 2025):

/oc find out what is causing this issue and then fix it please. Double check your work, follow best practices, avoid being verbose

the end of opencode session... you might need to triple check, since it doesn't run bun commands and doesn't typecheck properly. Other than that thank you for taking this issue @rekram1-node

@SHJordan commented on GitHub (Nov 21, 2025): > /oc find out what is causing this issue and then fix it please. Double check your work, follow best practices, avoid being verbose the end of opencode session... you might need to triple check, since it doesn't run bun commands and doesn't typecheck properly. Other than that thank you for taking this issue @rekram1-node
Author
Owner

@rekram1-node commented on GitHub (Dec 3, 2025):

@SHJordan how often do you see this? Haven't heard any other reports of it, wonder if your local setup got corrupted at some point. Assuming you rm -rf that bad dir, can you still reliably reproduce this?

@rekram1-node commented on GitHub (Dec 3, 2025): @SHJordan how often do you see this? Haven't heard any other reports of it, wonder if your local setup got corrupted at some point. Assuming you rm -rf that bad dir, can you still reliably reproduce this?
Author
Owner

@SHJordan commented on GitHub (Dec 3, 2025):

@SHJordan how often do you see this? Haven't heard any other reports of it, wonder if your local setup got corrupted at some point. Assuming you rm -rf that bad dir, can you still reliably reproduce this?

Not too often. But doing a rm -rf usually solves the issue with leftovers temp folders. my local setup is basically windows 11 + node lts, not really away from the usual i guess.

At some point i've also removed opencode and installed it on WSL2-Ubuntu (default distro for wsl2), was working as intended there.

Maybe is a platform specific bug.

@SHJordan commented on GitHub (Dec 3, 2025): > [@SHJordan](https://github.com/SHJordan) how often do you see this? Haven't heard any other reports of it, wonder if your local setup got corrupted at some point. Assuming you rm -rf that bad dir, can you still reliably reproduce this? Not too often. But doing a rm -rf usually solves the issue with leftovers temp folders. my local setup is basically windows 11 + node lts, not really away from the usual i guess. At some point i've also removed opencode and installed it on WSL2-Ubuntu (default distro for wsl2), was working as intended there. Maybe is a platform specific bug.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3030