gpt4 book ai didi

javascript - 为什么当我使用 npm run dev 时 vite.js 不工作

转载 作者:行者123 更新时间:2023-12-01 23:01:17 38 4
gpt4 key购买 nike

我用 Vite 创建了一个 React 应用程序,我使用 cd xxxxx 进入目录,我运行 npm install,然后我按照 npm run dev请帮助我,我不想使用 Create-react-app 太慢了。我一直在博客中搜索但没有任何效果,我更新了 node.js,弃用了 vite,删除了 vite 缓存,卸载了节点,卸载了 VScode

X [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.

X [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.
12:08:07 a. m. [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 inconsistent metadata for the path "node_modules/react/index.js" when it was imported here:
at failureErrorWithLog (C:\Users\feedm\Desktop\front\node_modules\esbuild\lib\main.js:1603:15)
at C:\Users\feedm\Desktop\front\node_modules\esbuild\lib\main.js:1249:28
at runOnEndCallbacks (C:\Users\feedm\Desktop\front\node_modules\esbuild\lib\main.js:1034:63)
at buildResponseToResult (C:\Users\feedm\Desktop\front\node_modules\esbuild\lib\main.js:1247:7)
at C:\Users\feedm\Desktop\front\node_modules\esbuild\lib\main.js:1356:14
at C:\Users\feedm\Desktop\front\node_modules\esbuild\lib\main.js:666:9
at handleIncomingPacket (C:\Users\feedm\Desktop\front\node_modules\esbuild\lib\main.js:763:9)
at Socket.readFromStdout (C:\Users\feedm\Desktop\front\node_modules\esbuild\lib\main.js:632:7)
at Socket.emit (node:events:526:28)
at addChunk (node:internal/streams/readable:315:12)

最佳答案

这是由 esbuild#2177 引起的(Vite 所依赖的),最近在 esbuild 0.14.36 版中恢复。

Vite 应该不会再出现此问题,但您必须删除所有锁定文件(即 package-lock.jsonyarn.lock 等。 ) 和 node_modules/,并重新安装依赖项,如 reported here .

关于javascript - 为什么当我使用 npm run dev 时 vite.js 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71837533/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com