unplugin/unplugin-auto-import

Monorepo架构下,根目录下启动子项目报错:Error: [auto-import] failed to load @vueuse/core, have you installed it?

MQYForverT opened this issue · 1 comments

Describe the bug

目录结构:

packages:
 + A
 +  + package.json -> start:vite
 +  + vite.config.ts

package.json  -> start: vite packages/A

我在A项目引入的@vueuse/core包,
然后在vite.config.ts中搭配AutoImport使用它:

AutoImport({
				imports: ['vue', '@vueuse/core'],
			}),

这样的配置,我在A目录下pnpm run start启动是正常的,

但是在根目录下启动pnpm run start命令会报错:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
Error: [auto-import] failed to load @vueuse/core, have you installed it?

我此时必须要在根目录下引入@vueuse/core才行。
或者自动导入不要加入@vueuse/core:

AutoImport({
				imports: ['vue'],
			}),

这就是我奇怪的地方,vue也是安装在A里面,为啥自动导入vue不报错,导入vueuse就报错。
另外,我启动的是vite packages/A,它不会自己找到A里面的@vueuse/core吗?

Reproduction

在生产

System Info

node - v:20.11.0
pnpm -v:9.0.6

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

We temporarily closed this due to the lack of enough information. We could not identify whether it was a bug or a userland misconfiguration with the given info.
Please provide a minimal reproduction to reopen the issue.
Thanks.

Why reproduction is required