Skip to content

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

Closed

Description

@SHJordan

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

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Nov 21, 2025
  2. SHJordan commented on Nov 21, 2025

    @SHJordan
    Author
    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

  3. self-assigned this
    on Nov 21, 2025
  4. removed
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Nov 21, 2025
  5. rekram1-node commented on Nov 21, 2025

    @rekram1-node
    Contributor

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

  6. rekram1-node commented on Nov 21, 2025

    @rekram1-node
    Contributor

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

  7. opencode-agent commented on Nov 21, 2025

    @opencode-agent
    Contributor

    Created PR #4602

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

  8. SHJordan commented on Nov 21, 2025

    @SHJordan
    Author

    /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

  9. rekram1-node commented on Dec 3, 2025

    @rekram1-node
    Contributor

    @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?

  10. SHJordan commented on Dec 3, 2025

    @SHJordan
    Author

    @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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions