I'm currently utilizing Vite for my project.
Within my vite.config.ts
file, the following code is present:
import { resolve } from "node:path"
import react from "@vitejs/plugin-react"
import { defineConfig } from "vite"
import dts from "vite-plugin-dts"
import tsConfigPaths from "vite-tsconfig-paths"
import pkg from "./package.json"
// Remaining configuration below
The issue arises specifically at
import pkg from "./package.json"
The complete error message reads:
TS2732: Cannot locate module './package.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.
It should be noted that package.json
unquestionably exists as a file, and its path is undeniably correct.
Both tsconfig.json
and tsconfig.vite.json
are configured with these settings:
"resolveJsonModule": true,
"esModuleInterop": true,
This issue persists regardless of restarting the TypeScript service or IDE.
Any suggestions on how to address this?