-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
环境
npm create vue@latest
创建的 Vue 3 项目。环境如下:
- macOS
- Node.js 20.12.2
- Vite 5.2.11
- pnpm 9.1.0
问题
配置如下:
chunkSplitPlugin({
strategy: 'default',
customSplitting: {
'vendor': ['vue'],
}
})
运行 vite build
提示以下错误:
error during build:
Error: Cannot find package 'vue' imported from /path/to/my/project
at __node_internal_ (file:///path/to/my/project/node_modules/.pnpm/[email protected]/node_modules/import-meta-resolve/lib/errors.js:436:11)
at new NodeError (file:///path/to/my/project/node_modules/.pnpm/[email protected]/node_modules/import-meta-resolve/lib/errors.js:380:5)
at packageResolve (file:///path/to/my/project/node_modules/.pnpm/[email protected]/node_modules/import-meta-resolve/lib/resolve.js:1035:9)
at moduleResolve (file:///path/to/my/project/node_modules/.pnpm/[email protected]/node_modules/import-meta-resolve/lib/resolve.js:1113:18)
at defaultResolve (file:///path/to/my/project/node_modules/.pnpm/[email protected]/node_modules/import-meta-resolve/lib/resolve.js:1289:15)
at resolve (file:///path/to/my/project/node_modules/.pnpm/[email protected]/node_modules/import-meta-resolve/index.js:32:12)
at resolveEntry (file:///path/to/my/project/node_modules/.pnpm/[email protected][email protected]_@[email protected][email protected]_/node_modules/vite-plugin-chunk-split/dist/index.mjs:53:10)
at file:///path/to/my/project/node_modules/.pnpm/[email protected][email protected]_@[email protected][email protected]_/node_modules/vite-plugin-chunk-split/dist/index.mjs:67:76
at Array.map (<anonymous>)
at wrapCustomSplitConfig (file:///path/to/my/project/node_modules/.pnpm/[email protected][email protected]_@[email protected][email protected]_/node_modules/vite-plugin-chunk-split/dist/index.mjs:67:62)
临时解决
把配置修改为:
chunkSplitPlugin({
strategy: 'default',
customSplitting: {
'vendor': [/\/vue\//],
}
})
可以正常打包。但不确定有什么不良后果。
感谢关注!
Metadata
Metadata
Assignees
Labels
No labels