nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.41k stars 2.33k forks source link

Vue: TS2307 "Cannot find module './app/App.vue'" #26543

Closed fabiog27 closed 2 months ago

fabiog27 commented 3 months ago

Current Behavior

In a monorepository with @nx/vue, opening the file apps/app-name/src/main.ts, there is a TS2307 error on the import of App.vue.

Expected Behavior

The import should be recognized correctly.

GitHub Repo

https://github.com/fabiog27/nx-dev-vue-ts-error

Steps to Reproduce

  1. Clone the provided repository
  2. Open the monorepository in IntelliJ (tested in 2024.1.3) or VS Code (tested in 1.90.0)
  3. Run a npm install
  4. Open the file apps/demo/src/main.ts

Nx Report

Node   : 20.11.0
OS     : darwin-arm64
npm    : 10.2.4

nx                 : 19.2.3
@nx/js             : 19.2.3
@nx/linter         : 19.2.3
@nx/eslint         : 19.2.3
@nx/workspace      : 19.2.3
@nx/cypress        : 19.2.3
@nx/devkit         : 19.2.3
@nx/eslint-plugin  : 19.2.3
@nrwl/tao          : 19.2.3
@nx/vite           : 19.2.3
@nx/vue            : 19.2.3
@nx/web            : 19.2.3
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/vite/plugin
@nx/cypress/plugin

Failure Logs

No response

Package Manager Version

No response

Operating System

Additional Information

I think it has to do with the language server that is picked for the file. In a standalone Vue project, it is the vue language server that is used even for the .ts files. In a monorepository, the TypeScript language server is used and the vue server is only used on .vue files.

On IntelliJ this can be forced with a .ws-context file in the workspace root with the following content:

{
  "framework": "typescript",
  "apps/demo/**": {
    "framework": "vue"
  }
}

However, this is cumbersome, and only works in IntelliJ.

Coly010 commented 3 months ago

Hey :) I'm unable to reproduce this error 🤔

Can you make sure you restart your TS server on vscode to see if you stil encounter it?

github-actions[bot] commented 3 months ago

This issue has been automatically marked as stale because more information has not been provided within 7 days. It will be closed in 21 days if no information is provided. If information has been provided, please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] commented 1 month ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.