sveltekit or esbuild error: Two output files share the same path but have different contents

sveltekit or esbuild error: Two output files share the same path but have different contents

刚才,我不知道为什么,当我在我的 sveltekit 项目上 运行 npm run dev 时,我得到了这个错误:

✘ [ERROR] Two output files share the same path but have different contents: node_modules/.vite/lodash_clonedeep.js.map

✘ [ERROR] Two output files share the same path but have different contents: node_modules/.vite/lodash_clonedeep.js

> Build failed with 2 errors:
error: Two output files share the same path but have different contents: node_modules/.vite/lodash_clonedeep.js.map
error: Two output files share the same path but have different contents: node_modules/.vite/lodash_clonedeep.js
error: Two output files share the same path but have different contents: node_modules/.vite/lodash_clonedeep.js.map
error: Two output files share the same path but have different contents: node_modules/.vite/lodash_clonedeep.js
    at failureErrorWithLog (/repos/personal/docsndata-monorepo/common/temp/node_modules/.pnpm/esbuild@0.14.25/node_modules/esbuild/lib/main.js:1605:15)
    at /repos/personal/docsndata-monorepo/common/temp/node_modules/.pnpm/esbuild@0.14.25/node_modules/esbuild/lib/main.js:1251:28
    at runOnEndCallbacks (/repos/personal/docsndata-monorepo/common/temp/node_modules/.pnpm/esbuild@0.14.25/node_modules/esbuild/lib/main.js:1036:63)
    at buildResponseToResult (/repos/personal/docsndata-monorepo/common/temp/node_modules/.pnpm/esbuild@0.14.25/node_modules/esbuild/lib/main.js:1249:7)
    at /repos/personal/docsndata-monorepo/common/temp/node_modules/.pnpm/esbuild@0.14.25/node_modules/esbuild/lib/main.js:1358:14
    at /repos/personal/docsndata-monorepo/common/temp/node_modules/.pnpm/esbuild@0.14.25/node_modules/esbuild/lib/main.js:668:9
    at handleIncomingPacket (/repos/personal/docsndata-monorepo/common/temp/node_modules/.pnpm/esbuild@0.14.25/node_modules/esbuild/lib/main.js:765:9)
    at Socket.readFromStdout (/repos/personal/docsndata-monorepo/common/temp/node_modules/.pnpm/esbuild@0.14.25/node_modules/esbuild/lib/main.js:635:7)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12)

我已经这样做了数百次并且成功了。

以防万一,我的 repo 是一个 rushjs monorepo,我不断地使用它更新我的依赖项,所以也许某些版本在我的依赖项树中碰到了某个地方,但我不知道如何调试它.

导致此错误的原因是什么?

好的,问题是我的应用程序中的一个模块像这样导入了 lodash cloneDeep

import cloneDeep from lodash/cloneDeep

即来自完整的 lodash npm 模块。

我的另一个模块使用更有针对性的 npm 模块导入它

import cloneDeep from "lodash.clonedeep"

一个非常令人困惑的错误消息,但我想它有一定的道理。

修复是一致地导入 cloneDeep,我选择了后一种方法。