我有跟随PR,当我在本地测试时,vite命令可以正常工作,但是vite build命令失败的方式与github操作失败的方式相同。为什么vite build要扔..。
~/Code/personal/example-vue-vite on REMOVE_CDN>npx vite build
vite v3.1.4 building for production...
error during build:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at new NodeError (node:internal/errors:377:5)
at validateString (node:internal/validators:119:11)
at Object.resolve (node:path:1098:7)
at resolve (file:///.../example-vue-vite/node_modules/vite/dist/node/chunks/dep-6b3a5aff.js:45670:35)
at doBuild (file:///.../example-vue-vite/node_modules/vite/dist/node/chunks/dep-6b3a5aff.js:45672:43)
at async build (file:///.../example-vue-vite/node_modules/vite/dist/node/chunks/dep-6b3a5aff.js:45654:16)
at async CAC.<anonymous> (file:///.../example-vue-vite/node_modules/vite/dist/node/cli.js:748:9)build: {
minify: true,
soucemap: "inline",
lib: {
name: 'index',
formats: ['es'],
}
},我错过了什么,如何让vite build工作呢?
另外,要明确的是,即使在Github操作中,Vitest测试也可以正常工作,只有构建失败。
发布于 2022-09-28 15:46:04
好的,问题在于我的vite配置方式。我需要以下的..。
import { fileURLToPath } from 'url';
import { dirname, resolve } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);然后我需要像这样改变我的自由..。
lib: {
entry: resolve(__dirname, 'src/index.mjs'),
fileName: "exampleApp",
name: "exampleApp",
formats: ['es'],
}现在它正确地构建了
https://stackoverflow.com/questions/73884192
复制相似问题