I’m developing a single-page application (SPA) using the Quasar framework with TypeScript. My project has two distinct directories: one for the backend, which uses Express and Node.js, and another for the frontend that employs Quasar CLI along with Vite.
The challenge I’m encountering is that when I work in the frontend directory in VSCode, it imports types from Node.js. This results in the SetInterval
function returning NodeJS.Timeout
instead of a standard number, which is the expected behavior in a browser context.
I believe this occurs because Quasar’s dependencies may be including @types/node
automatically. Below is my current project configuration:
{
"name": "webapp-frontend",
"version": "1.0.0",
"dependencies": {
"@quasar/extras": "^1.16.4",
"axios": "^1.2.1",
"vue": "^3.0.0",
"vue-router": "^4.0.0",
"pinia": "^2.0.11",
"quasar": "^2.6.0"
},
"devDependencies": {
"@quasar/app-vite": "^1.3.0",
"typescript": "^4.5.4",
"@typescript-eslint/parser": "^5.10.0"
},
"scripts": {
"serve": "quasar dev",
"compile": "quasar build"
}
}
I attempted to eliminate @types/node
using package overrides, but the issue persists due to local copies in nested dependencies. What is the recommended approach to stop Node.js types from affecting the browser code in this environment?