nx
nx copied to clipboard
Vue: TS2307 "Cannot find module './app/App.vue'"
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
- Clone the provided repository
- Open the monorepository in IntelliJ (tested in 2024.1.3) or VS Code (tested in 1.90.0)
- Run a
npm install - 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
- [X] macOS
- [ ] Linux
- [ ] Windows
- [ ] Other (Please specify)
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.
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?
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! 🙏
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.