-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Labels
p3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)
Description
Describe the bug
Vite 3.0.1 and higher does not seem to resolve projects within the monorepo.
E.g. we got structure:
├─ apps
│ └─ app1
└─ vite.config.ts
│ └─ app2
└─ packages
└─ package1
└─ package2
Since vite@3.0.1., I'm getting the error below:
Error: Cannot find module 'C:\Apps\repo\packages\common\src\types'
Require stack:
- C:\Apps\repo\apps\admin\vite.config.ts
- C:\Apps\repo\node_modules\.pnpm\vite@3.0.2_sass@1.32.13\node_modules\vite\dist\node\chunks\dep-1513d487.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Apps\repo\apps\admin\vite.config.ts:117:20)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object._require.extensions.<computed> [as .js] (file:///C:/Apps/repo/node_modules/.pnpm/vite@3.0.2_sass@1.32.13/node_modules/vite/dist/node/chunks/dep-1513d487.js:62817:24)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
This was working fine up till vite@3.0.0 and breaks in vite@3.0.1 and up.
Vite now fails on relative import in vite.config.ts
import { something } from '../../packages/common/src/types';
Is there a more proper way to do this in vite?
Reproduction
https://stackblitz.com/edit/vitejs-vite-wg28sd?file=apps/app/vite.config.ts
cd apps/app
npm install
npm run buildSystem Info
System:
OS: Windows 10 10.0.22000
CPU: (4) x64 Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz
Memory: 3.85 GB / 15.86 GB
Binaries:
Node: 16.13.0 - C:\Program Files\nodejs\node.EXE
npm: 8.1.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 103.0.5060.114
Edge: Spartan (44.22000.120.0), Chromium (102.0.1245.44)
Internet Explorer: 11.0.22000.120
pnpm@v6.33.1Used Package Manager
pnpm (own project) / npm (stackblitz)
Logs
Error: Cannot find module 'C:\Apps\repo\packages\common\src\types'
Require stack:
- C:\Apps\repo\apps\admin\vite.config.ts
- C:\Apps\repo\node_modules\.pnpm\vite@3.0.2_sass@1.32.13\node_modules\vite\dist\node\chunks\dep-1513d487.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Apps\repo\apps\admin\vite.config.ts:117:20)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object._require.extensions.<computed> [as .js] (file:///C:/Apps/repo/node_modules/.pnpm/vite@3.0.2_sass@1.32.13/node_modules/vite/dist/node/chunks/dep-1513d487.js:62817:24)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
p3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)
Type
Projects
Status
Discussing