vite 项目启动时打开chrome 浏览器, 报错,怎么改呢?
node:_http_client:160
throw new ERR_UNESCAPED_CHARACTERS('Request path');
^
TypeError [ERR_UNESCAPED_CHARACTERS]: Request path contains unescaped characters
import { fileURLToPath, URL } from 'node:url'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
// https://vitejs.dev/config/
export default defineConfig((command, mode) => {
const env = loadEnv(mode, process.cwd());
console.log(env.VITE_BROWSER)
return {
plugins: [
vue(),
vueJsx(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
host: "0.0.0.0",
open: env.VITE_BROWSER
}
}
}
)
.env
VITE_BROWSER='C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'
我现在是这么改的
.env
把
chrome
所在目录配置到环境变量中,C:\Program Files\Google\Chrome\Application
然后在
vite.config.js
中添加