vite: Inconsistent Metadata errors

Describe the bug

I get this when starting my dev server

✘ [ERROR] [plugin vite:dep-pre-bundle] Detected inconsistent metadata for the path "node_modules/vue/dist/vue.runtime.esm-bundler.js" when it was imported here:

    node_modules/vue-router/dist/vue-router.esm-bundler.js:6:187:
      6 │ ...eactive, h, provide, ref, watch, shallowRef, nextTick } from 'vue';
        ╵                                                                 ~~~~~

  The original metadata for that path comes from when it was imported here:

    dep:vue:2:14:
      2 │ export * from "./node_modules/vue/dist/vue.runtime.esm-bundler.js"
        ╵               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  The difference in metadata is displayed below:

   {
  -  "pluginName": null,
  +  "pluginName": "vite:dep-pre-bundle",
   }

  This is a bug in the "vite:dep-pre-bundle" plugin. Plugins provide metadata for a given path in an "onResolve" callback. All metadata provided for the same path must be consistent to ensure deterministic builds. Due to parallelism, one set of provided metadata will be randomly chosen for a given path, so providing inconsistent metadata for the same path can cause non-determinism.

Possible duplicate of https://github.com/vitejs/vite/issues/7683

Reproduction

https://stackblitz.com/edit/vitejs-vite-f48pac?file=package.json

System Info

System:
    OS: macOS 12.0.1
    CPU: (8) arm64 Apple M1
    Memory: 95.61 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.volta/tools/image/node/16.13.1/bin/node
    Yarn: 1.22.17 - ~/.volta/tools/image/yarn/1.22.17/bin/yarn
    npm: 8.6.0 - ~/.volta/tools/image/npm/8.6.0/bin/npm
  Browsers:
    Chrome: 100.0.4896.75
    Safari: 15.1
  npmPackages:
    @vitejs/plugin-vue: ^2.3.1 => 2.3.1
    vite: ^2.9.1 => 2.9.1

Used Package Manager

yarn

Logs

vite:resolve 0.31ms @vue/runtime-dom -> /Users/k/fume/tailvue/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +0ms
  vite:resolve 0.41ms vue -> /Users/k/fume/tailvue/node_modules/vue/dist/vue.runtime.esm-bundler.js +3ms
✘ [ERROR] [plugin vite:dep-pre-bundle] Detected inconsistent metadata for the path "node_modules/vue/dist/vue.runtime.esm-bundler.js" when it was imported here:

    node_modules/@iconify/vue/dist/iconify.mjs:1:35:
      1 │ import { h, defineComponent } from 'vue';
        ╵                                    ~~~~~

  The original metadata for that path comes from when it was imported here:

    dep:vue:2:14:
      2 │ export * from "../node_modules/vue/dist/vue.runtime.esm-bundler.js"
        ╵               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  The difference in metadata is displayed below:

   {
  -  "pluginName": null,
  +  "pluginName": "vite:dep-pre-bundle",
   }

  This is a bug in the "vite:dep-pre-bundle" plugin. Plugins provide metadata for a given path in an
  "onResolve" callback. All metadata provided for the same path must be consistent to ensure
  deterministic builds. Due to parallelism, one set of provided metadata will be randomly chosen for
  a given path, so providing inconsistent metadata for the same path can cause non-determinism.

  vite:resolve 0.33ms @vue/runtime-core -> /Users/k/fume/tailvue/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +1ms
  vite:resolve 0.27ms @vue/shared -> /Users/k/fume/tailvue/node_modules/@vue/shared/dist/shared.esm-bundler.js +0ms
  vite:resolve 0.39ms @vue/reactivity -> /Users/k/fume/tailvue/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js +10ms
11:03:58 PM [vite] error while updating dependencies:
Error: Build failed with 1 error:

Validations

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 12
  • Comments: 24 (2 by maintainers)

Most upvoted comments

The issue seems related to esbuild

A temporary workaround is to add resolution to your package.json:

"resolutions": {
  "esbuild": "0.14.34"
}

The issue seems related to esbuild

A temporary workaround is to add resolution to your package.json:

"resolutions": {
  "esbuild": "0.14.34"
}

Thank man 👍!

Thank you, works.

Also, i’m using npm not yarn so if anyone comes here using npm, fyi its equivalent is overrides

"overrides": {
    "esbuild": "0.14.34"
  },

The issue seems related to esbuild

A temporary workaround is to add resolution to your package.json:

"resolutions": {
  "esbuild": "0.14.34"
}

Abeiv

谢谢呢 “resolutions”: { “esbuild”: “0.14.34” } 这个方法很好,虽然不知道为什么

原因是vite的依赖包esbuild今天上午发布了一个新版本0.14.35,有问题。0.14.34是没问题的。简单来说,resolutions是yarn的固定版本的一个方法。刚刚,esbuild又发布了一个新版本0.14.36,解决了这个问题

Please remove the custom resolutions, esbuild 0.14.36 has been released reverting the problematic change

Happens with VUE JS as well ` node_modules/.pnpm/vue-router@4.0.14_vue@3.2.31/node_modules/vue-router/dist/vue-router.esm-bundler.js:6:187: 6 │ …t, onUnmounted, onDeactivated, onActivated, computed, unref, watchEffect, defineComponent, reactive, h, provide, ref, watch, shallowRef, nextTick } from ‘vue’; ╵ ~~~~~

The original metadata for that path comes from when it was imported here:

dep:vue:2:14:
  2 │ export * from "./node_modules/.pnpm/vue@3.2.31/node_modules/vue/dist/vue.runtime.esm-bundler.js"
    ╵               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The difference in metadata is displayed below:

{

  • “pluginName”: null,
  • “pluginName”: “vite:dep-pre-bundle”, }

This is a bug in the “vite:dep-pre-bundle” plugin. Plugins provide metadata for a given path in an “onResolve” callback. All metadata provided for the same path must be consistent to ensure deterministic builds. Due to parallelism, one set of provided metadata will be randomly chosen for a given path, so providing inconsistent metadata for the same path can cause non-determinism.

下午12:21:14 [vite] error while updating dependencies: Error: Build failed with 1 error: node_modules/.pnpm/vue-router@4.0.14_vue@3.2.31/node_modules/vue-router/dist/vue-router.esm-bundler.js:6:187: ERROR: [plugin: vite:dep-pre-bundle] Detected inconsistent metadata for the path “node_modules/.pnpm/vue@3.2.31/node_modules/vue/dist/vue.runtime.esm-bundler.js” when it was imported here: at failureErrorWithLog (E:\demo\2022\my-vue-app\node_modules.pnpm\esbuild@0.14.35\node_modules\esbuild\lib\main.js:1603:15) at E:\demo\2022\my-vue-app\node_modules.pnpm\esbuild@0.14.35\node_modules\esbuild\lib\main.js:1249:28 at runOnEndCallbacks (E:\demo\2022\my-vue-app\node_modules.pnpm\esbuild@0.14.35\node_modules\esbuild\lib\main.js:1034:63) at buildResponseToResult (E:\demo\2022\my-vue-app\node_modules.pnpm\esbuild@0.14.35\node_modules\esbuild\lib\main.js:1247:7) at E:\demo\2022\my-vue-app\node_modules.pnpm\esbuild@0.14.35\node_modules\esbuild\lib\main.js:1356:14 at E:\demo\2022\my-vue-app\node_modules.pnpm\esbuild@0.14.35\node_modules\esbuild\lib\main.js:666:9 at handleIncomingPacket (E:\demo\2022\my-vue-app\node_modules.pnpm\esbuild@0.14.35\node_modules\esbuild\lib\main.js:763:9) at Socket.readFromStdout (E:\demo\2022\my-vue-app\node_modules.pnpm\esbuild@0.14.35\node_modules\esbuild\lib\main.js:632:7) at Socket.emit (node:events:390:28) at addChunk (node:internal/streams/readable:315:12) Vite Error, /node_modules/.vite/deps/vue-router.js?v=18f23ae8 optimized info should be defined X [ERROR] [plugin vite:dep-pre-bundle] Detected inconsistent metadata for the path “node_modules/.pnpm/vue@3.2.31/node_modules/vue/dist/vue.runtime.esm-bundler.js” when it was imported here:

node_modules/.pnpm/vue-router@4.0.14_vue@3.2.31/node_modules/vue-router/dist/vue-router.esm-bundler.js:6:187:
  6 │ ...t, onUnmounted, onDeactivated, onActivated, computed, unref, watchEffect, defineComponent, reactive, h, provide, ref, watch, shallowRef, nextTick } from 'vue'; 
    ╵                                                                                                                                                             ~~~~~  

The original metadata for that path comes from when it was imported here:

dep:vue:2:14:
  2 │ export * from "./node_modules/.pnpm/vue@3.2.31/node_modules/vue/dist/vue.runtime.esm-bundler.js"
    ╵               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The difference in metadata is displayed below:

{

  • “pluginName”: null,
  • “pluginName”: “vite:dep-pre-bundle”, }

This is a bug in the “vite:dep-pre-bundle” plugin. Plugins provide metadata for a given path in an “onResolve” callback. All metadata provided for the same path must be consistent to ensure deterministic builds. Due to parallelism, one set of provided metadata will be randomly chosen for a given path, so providing inconsistent metadata for the same path can cause non-determinism.

下午12:21:19 [vite] error while updating dependencies: Error: Build failed with 1 error: node_modules/.pnpm/vue-router@4.0.14_vue@3.2.31/node_modules/vue-router/dist/vue-router.esm-bundler.js:6:187: ERROR: [plugin: vite:dep-pre-bundle] Detected inconsistent metadata for the path “node_modules/.pnpm/vue@3.2.31/node_modules/vue/dist/vue.runtime.esm-bundler.js” when it was imported here: at failureErrorWithLog (E:\demo\2022\my-vue-app\node_modules.pnpm\esbuild@0.14.35\node_modules\esbuild\lib\main.js:1603:15) at E:\demo\2022\my-vue-app\node_modules.pnpm\esbuild@0.14.35\node_modules\esbuild\lib\main.js:1249:28 at runOnEndCallbacks (E:\demo\2022\my-vue-app\node_modules.pnpm\esbuild@0.14.35\node_modules\esbuild\lib\main.js:1034:63) at buildResponseToResult (E:\demo\2022\my-vue-app\node_modules.pnpm\esbuild@0.14.35\node_modules\esbuild\lib\main.js:1247:7) at E:\demo\2022\my-vue-app\node_modules.pnpm\esbuild@0.14.35\node_modules\esbuild\lib\main.js:1356:14 at E:\demo\2022\my-vue-app\node_modules.pnpm\esbuild@0.14.35\node_modules\esbuild\lib\main.js:666:9 at handleIncomingPacket (E:\demo\2022\my-vue-app\node_modules.pnpm\esbuild@0.14.35\node_modules\esbuild\lib\main.js:763:9) at Socket.readFromStdout (E:\demo\2022\my-vue-app\node_modules.pnpm\esbuild@0.14.35\node_modules\esbuild\lib\main.js:632:7) at Socket.emit (node:events:390:28) at addChunk (node:internal/streams/readable:315:12) `

Happens with React JS and React TS as well

$ vite

  vite v2.9.1 dev server running at:

  > Local: http://localhost:3000/
  > Network: use `--host` to expose

  ready in 271ms.

✘ [ERROR] [plugin vite:dep-pre-bundle] Detected inconsistent metadata for the path "node_modules/react/index.js" when it was imported here:

    node_modules/react/cjs/react-jsx-dev-runtime.development.js:16:20:
      16 │ var React = require('react');
         ╵                     ~~~~~~~

  The original metadata for that path comes from when it was imported here:

    dep:react:1:23:
      1 │ export default require("./node_modules/react/index.js");
        ╵                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  The difference in metadata is displayed below:

   {
  -  "pluginName": null,
  +  "pluginName": "vite:dep-pre-bundle",
   }

  This is a bug in the "vite:dep-pre-bundle" plugin. Plugins provide metadata for a given path in an
  "onResolve" callback. All metadata provided for the same path must be consistent to ensure
  deterministic builds. Due to parallelism, one set of provided metadata will be randomly chosen for
  a given path, so providing inconsistent metadata for the same path can cause non-determinism.

✘ [ERROR] [plugin vite:dep-pre-bundle] Detected inconsistent metadata for the path "node_modules/react/index.js" when it was imported here:

    node_modules/react-dom/cjs/react-dom.development.js:16:20:
      16 │ var React = require('react');
         ╵                     ~~~~~~~

  The original metadata for that path comes from when it was imported here:

    dep:react:1:23:
      1 │ export default require("./node_modules/react/index.js");
        ╵                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  The difference in metadata is displayed below:

   {
  -  "pluginName": null,
  +  "pluginName": "vite:dep-pre-bundle",
   }

  This is a bug in the "vite:dep-pre-bundle" plugin. Plugins provide metadata for a given path in an
  "onResolve" callback. All metadata provided for the same path must be consistent to ensure
  deterministic builds. Due to parallelism, one set of provided metadata will be randomly chosen for
  a given path, so providing inconsistent metadata for the same path can cause non-determinism.

10:49:37 PM [vite] error while updating dependencies:
Error: Build failed with 2 errors:
node_modules/react-dom/cjs/react-dom.development.js:16:20: ERROR: [plugin: vite:dep-pre-bundle] Detected inconsistent metadata for the path "node_modules/react/index.js" when it was imported here:
node_modules/react/cjs/react-jsx-dev-runtime.development.js:16:20: ERROR: [plugin: vite:dep-pre-bundle] Detected inconsi    at failureErrorWithLog (D:\projects\web-projects\test\node_modules\esbuild\lib\main.js:1603:15)
    at D:\projects\web-projects\test\node_modules\esbuild\lib\main.js:1249:28
    at runOnEndCallbacks (D:\projects\web-projects\test\node_modules\esbuild\lib\main.js:1034:63)
    at buildResponseToResult (D:\projects\web-projects\test\node_modules\esbuild\lib\main.js:1247:7)
    at D:\projects\web-projects\test\node_modules\esbuild\lib\main.js:666:9
    at Socket.readFromStdout (D:\projects\web-projects\test\node_modules\esbuild\lib\main.js:632:7)
    at Socket.emit (events.js:321:20)
    at addChunk (_stream_readable.js:294:12)