0

刚才,我无缘无故地弄清楚,当我npm run dev在我的 sveltekit 项目上运行时,我收到了这个错误:

✘ [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,我不断地使用它更新我的依赖项,所以也许某些版本在我的依赖项树中碰到了某个地方,但我不知道如何调试它。

是什么导致了这个错误?

4

1 回答 1

0

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

import cloneDeep from lodash/cloneDeep

即来自完整的 lodash npm 模块。

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

import cloneDeep from "lodash.clonedeep"

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

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

于 2022-03-04T20:55:22.993 回答