You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: Leftover dot-prefixed temp directory in global node_modules breaks npm -g update on Windows #4592
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
Install opencode-ai globally on Windows (npm i -g opencode-ai).
(Trigger condition unclear, possibly during install or first run).
Observe a directory like .opencode-ai-xxxxxx in %APPDATA%\npm\node_modules.
/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 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?
@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.
Activity
SHJordan commentedon 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
rekram1-node commentedon Nov 21, 2025
Ill fix it, but let's see if the bot can help
rekram1-node commentedon 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
opencode-agent commentedon Nov 21, 2025
Created PR #4602
opencode session | github run
SHJordan commentedon Nov 21, 2025
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
rekram1-node commentedon 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?
SHJordan commentedon Dec 3, 2025
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.