Skip to content

Cannot find modules from compilerOptions.paths in bun vite react typescript project #965

@fxf8

Description

@fxf8

Editor: Neovim with Mason lsp
ts-ls version: 4.3.4

Mason nvim info:
https://pastebin.com/fx8ANnH4

Output of LspInfo under Active Clients:

vim.lsp: Active Clients ~
- ts_ls (id: 1)
  - Version: ? (no serverInfo.version response)
  - Root directory: ~/Projects/larss/frontend/larss-frontend
  - Command: { "typescript-language-server", "--stdio" }
  - Settings: {}
  - Attached buffers: 4

Contents of tsconfig.json:

{
    "files": [],
    "references": [
        {
            "path": "./tsconfig.app.json"
        },
        {
            "path": "./tsconfig.node.json"
        }
    ],
    "compilerOptions": {
        "baseUrl": ".",
        "paths": {
            "@larss-bindings/*": [
                "../../bindings/*"
            ]
        }
    }
}

tsconfig.app.json:

{
  "compilerOptions": {
    "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
    "target": "ES2022",
    "useDefineForClassFields": true,
    "lib": ["ES2022", "DOM", "DOM.Iterable"],
    "module": "ESNext",
    "skipLibCheck": true,

    /* Bundler mode */
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "verbatimModuleSyntax": true,
    "moduleDetection": "force",
    "noEmit": true,
    "jsx": "react-jsx",

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "erasableSyntaxOnly": true,
    "noFallthroughCasesInSwitch": true,
    "noUncheckedSideEffectImports": true
  },
  "include": ["src"]
}

tsconfig.node.json

{
  "compilerOptions": {
    "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
    "target": "ES2023",
    "lib": ["ES2023"],
    "module": "ESNext",
    "skipLibCheck": true,

    /* Bundler mode */
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "verbatimModuleSyntax": true,
    "moduleDetection": "force",
    "noEmit": true,

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "erasableSyntaxOnly": true,
    "noFallthroughCasesInSwitch": true,
    "noUncheckedSideEffectImports": true
  },
  "include": ["vite.config.ts"]
}

package.json

{
    "name": "larss-frontend",
    "private": true,
    "version": "0.0.0",
    "type": "module",
    "scripts": {
        "dev": "vite",
        "build": "tsc -b && vite build",
        "lint": "eslint .",
        "preview": "vite preview"
    },
    "dependencies": {
        "@types/node": "^24.1.0",
        "path": "^0.12.7",
        "react": "^19.1.0",
        "react-dnd": "^16.0.1",
        "react-dom": "^19.1.0",
        "zustand": "^5.0.6"
    },
    "devDependencies": {
        "@eslint/js": "^9.30.1",
        "@types/react": "^19.1.8",
        "@types/react-dom": "^19.1.6",
        "@vitejs/plugin-react-swc": "^3.10.2",
        "eslint": "^9.30.1",
        "eslint-plugin-react-hooks": "^5.2.0",
        "eslint-plugin-react-refresh": "^0.4.20",
        "globals": "^16.3.0",
        "typescript": "~5.8.3",
        "typescript-eslint": "^8.35.1",
        "vite": "^7.0.4"
    }
}

Also, this project was built using vite and react. For the import statement:

import { type Shape } from '@larss-bindings/Shape';

ts_ls raises the diagnostic error:

1. typescript: Cannot find module '@larss-bindings/Shape' or its corresponding type declarations. [2307]

However, the issue is that the program itself runs successfully despite the error (using the command bun run dev). This is my configuration for ts_ls in case it helps:

(full file here: https://github.com/fxf8/dotfiles/blob/main/nvim/lua/plugins/lsp.lua)

vim.lsp.config("ts_ls", {
    on_attach = on_attach,
    capabilities = capabilities,
})

Given that the import statement is able to execute without error, I believe the issue is in the LSP (unless I have configured it incorrectly).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions