failed to load config from D:\HBuilderX\plugins\uniapp-cli-vite\vite.config.js

failed to load config from D:\HBuilderX\plugins\uniapp-cli-vite\vite.config.js

HBuilderX小程序编译运行异常。


问题描述

error during build:
Error:
You installed esbuild for another platform than the one you’re currently using.
This won’t work because esbuild is written with native code and needs to
install a platform-specific binary executable.
Specifically the “esbuild-windows-32” package is present but this platform
needs the “esbuild-windows-64” package instead. People often get into this
situation by installing esbuild on Windows or macOS and copying “node_modules”
into a Docker image that runs Linux, or by copying “node_modules” between
Windows and WSL environments.
If you are installing with npm, you can try not copying the “node_modules”
directory when you copy the files over, and running “npm ci” or “npm install”
on the destination platform after the copy. Or you could consider using yarn
instead of npm which has built-in support for installing a package on multiple
platforms simultaneously.
If you are installing with yarn, you can try listing both this platform and the
other platform in your “.yarnrc.yml” file using the “supportedArchitectures”
feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
Keep in mind that this means multiple copies of esbuild will be present.
Another alternative is to use the “esbuild-wasm” package instead, which works
the same way on all platforms. But it comes with a heavy performance cost and
can sometimes be 10x slower than the “esbuild” package, so you may also not
want to do that.:


原因分析:

安装的esbuild是为不同于当前使用的平台编写的。这是因为esbuild使用了本地代码,需要安装特定平台的本机二进制可执行文件。

具体来说“esbuild-windows-64”包,但安装的是“esbuild-windows-32”包。这种情况通常发生在在Windows或macOS上安装esbuild并将“node_modules”复制到运行Linux的Docker镜像中,或者在Windows和WSL环境之间复制“node_modules”。


解决方案:

1.删除HBuilderX安装目录->plugins下的uniapp-cli-vite文件夹
2.重新执行HBuilderX小程序运行流程即可

=> ERROR [vue_app build 6/6] RUN npm run build 8.7s ------ > [vue_app build 6/6] RUN npm run build: 0.579 0.579 > vue_learn@0.0.0 build 0.579 > vue-tsc -b && vite build 0.579 8.514 ▲ [WARNING] The CommonJS "module" variable is treated as a global variable in an ECMAScript module and may not work as expected [commonjs-variable-in-esm] 8.514 8.514 vite.config.ts:32:0: 8.514 32 │ module.exports = { 8.514 ╵ ~~~~~~ 8.514 8.514 This file is considered to be an ECMAScript module because of the "export" keyword here: 8.514 8.514 vite.config.ts:6:0: 8.514 6 │ export default defineConfig({ 8.514 ╵ ~~~~~~ 8.514 8.610 failed to load config from /app/vite.config.ts 8.615 error during build: 8.615 ReferenceError: module is not defined in ES module scope 8.615 at file:///app/node_modules/.vite-temp/vite.config.ts.timestamp-1744012997583-aad75c07ea95a.mjs:34:1 8.615 at ModuleJob.run (node:internal/modules/esm/module_job:193:25) 8.615 at async Promise.all (index 0) 8.615 at async ESMLoader.import (node:internal/modules/esm/loader:530:24) 8.615 at async loadConfigFromBundledFile (file:///app/node_modules/vite/dist/node/chunks/dep-B0fRCRkQ.js:54640:15) 8.615 at async bundleAndLoadConfigFile (file:///app/node_modules/vite/dist/node/chunks/dep-B0fRCRkQ.js:54483:22) 8.615 at async loadConfigFromFile (file:///app/node_modules/vite/dist/node/chunks/dep-B0fRCRkQ.js:54445:44) 8.615 at async resolveConfig (file:///app/node_modules/vite/dist/node/chunks/dep-B0fRCRkQ.js:53944:24) 8.615 at async createBuilder (file:///app/node_modules/vite/dist/node/chunks/dep-B0fRCRkQ.js:51949:18) 8.615 at async CAC.<anonymous> (file:///app/node_modules/vite/dist/node/cli.js:859:23) ------ failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1
04-08
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值