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
TypeScript LSP server is not used if package.json is in a sub-directory #18694
changed the title [-]TypeScript LSP server is not used it package.json is in a sub-directory[/-][+]TypeScript LSP server is not used if package.json is in a sub-directory[/+]on Mar 23, 2026
This issue might be a duplicate of existing issues. Please check:
LSP detection in monorepo not working #7690: LSP detection in monorepo not working — same root cause: TypeScript/ESLint LSP not enabled when opencode is started from the git root rather than the frontend subdirectory containing package.json.
But the OpenCode log shows TypeScript LSP startup was attempted:
service=lsp.server typescript server
There is no tsserver path in that log entry. From the current TypeScript LSP implementation, this appears to mean typescript/lib/tsserver.js is being resolved from the OpenCode launch directory / instance directory rather than from the detected TypeScript workspace root for the target file.
This does not look like a file extension support issue: the .ts file was recognized far enough for TypeScript LSP startup to be attempted. It also does not look like an lsp config gate in this case: "lsp": {} is valid per the current docs, and the log shows permission=lsp evaluated as allowed.
I also found the earlier attempts/discussion around this: #7690, #16335, #7691, and #17359. The PRs appear to be closed/stale, and I do not see an active PR covering the TypeScript-specific root-resolution case.
Proposed narrow first fix:
for TypeScript LSP startup, resolve typescript/lib/tsserver.js from the detected LSP/workspace root first;
fall back to the OpenCode launch directory to preserve current behavior;
keep the PR TypeScript-only;
improve the failure log when tsserver cannot be resolved;
add regression coverage or a manual repro for a repo root with apps/api/package.json + apps/api/node_modules/typescript.
A broader workspace-aware LSP resolver could happen separately, but this TypeScript-only change seems small and should address this issue without a larger LSP-manager redesign.
Before I work on a PR, would maintainers be open to this narrow direction?
If there was a configuration-driven only fix for this, like we suggest where the LSP roots (package.json) files are, and it picks those up, that will be fine for most monorepo use cases too
This is a problem for me as well as most of my projects are separated into backend and frontend projects that are not in the root. The Python LSP (backend) is found correctly, but the Typescript LSP (frontend) is never loaded.
Just wanted to push this. Putting backend and frontend project configuration files in different subdirectories is a really common practice and most tools have no problem with finding the correct configs to apply before running any form of linter or lsp.
Edit: Just saw that #35396 already contains an analysis of the problem and proposes a fix.
Some time in the last few weeks, they've added the ability to change the folder of an ongoing opencode session. That feature addition makes it simpler for some usecases
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.
Activity
[-]TypeScript LSP server is not used it package.json is in a sub-directory[/-][+]TypeScript LSP server is not used if package.json is in a sub-directory[/+]github-actions commentedon Mar 23, 2026
This issue might be a duplicate of existing issues. Please check:
package.json.samiralibabic commentedon May 8, 2026
Very much needed.
samiralibabic commentedon May 8, 2026
I can reproduce this same failure mode on OpenCode
1.14.41with a TypeScript package in a child directory.Local repro, with paths sanitized:
/repohas nopackage.json/node_modules, while/repo/apps/apiis the actual TypeScript package and can resolve:The live LSP tool reports:
But the OpenCode log shows TypeScript LSP startup was attempted:
There is no
tsserverpath in that log entry. From the current TypeScript LSP implementation, this appears to meantypescript/lib/tsserver.jsis being resolved from the OpenCode launch directory / instance directory rather than from the detected TypeScript workspace root for the target file.This does not look like a file extension support issue: the
.tsfile was recognized far enough for TypeScript LSP startup to be attempted. It also does not look like anlspconfig gate in this case:"lsp": {}is valid per the current docs, and the log showspermission=lspevaluated as allowed.I also found the earlier attempts/discussion around this: #7690, #16335, #7691, and #17359. The PRs appear to be closed/stale, and I do not see an active PR covering the TypeScript-specific root-resolution case.
Proposed narrow first fix:
typescript/lib/tsserver.jsfrom the detected LSP/workspace root first;tsservercannot be resolved;apps/api/package.json+apps/api/node_modules/typescript.A broader workspace-aware LSP resolver could happen separately, but this TypeScript-only change seems small and should address this issue without a larger LSP-manager redesign.
Before I work on a PR, would maintainers be open to this narrow direction?
sankalpmukim commentedon May 13, 2026
If there was a configuration-driven only fix for this, like we suggest where the LSP roots (package.json) files are, and it picks those up, that will be fine for most monorepo use cases too
nelsonwellswku commentedon Jul 5, 2026
This is a problem for me as well as most of my projects are separated into backend and frontend projects that are not in the root. The Python LSP (backend) is found correctly, but the Typescript LSP (frontend) is never loaded.
punsii commentedon Aug 13, 2026
Just wanted to push this. Putting backend and frontend project configuration files in different subdirectories is a really common practice and most tools have no problem with finding the correct configs to apply before running any form of linter or lsp.
Edit: Just saw that #35396 already contains an analysis of the problem and proposes a fix.
sankalpmukim commentedon Aug 13, 2026
Some time in the last few weeks, they've added the ability to change the folder of an ongoing opencode session. That feature addition makes it simpler for some usecases
thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊