Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows 下无法运行和编译 console #4874

Closed
longjuan opened this issue Nov 18, 2023 · 1 comment · Fixed by #4877
Closed

windows 下无法运行和编译 console #4874

longjuan opened this issue Nov 18, 2023 · 1 comment · Fixed by #4877
Assignees
Labels
area/console Issues or PRs related to the Halo Console kind/bug Categorizes issue or PR as related to a bug.

Comments

@longjuan
Copy link
Member

longjuan commented Nov 18, 2023

是什么版本出现了此问题?

main

使用的什么数据库?

H2

使用的哪种方式运行?

Source Code

在线站点地址

No response

发生了什么?

运行和编译 console 时发生路径的处理问题
outDir:
外面 config.ts 中 resolve 成了绝对路径,但没有加上协议头,导致运行报错

outDir: path.resolve("../application/src/main/resources/console"),

outDir: fileURLToPath(new URL(outDir, import.meta.url)),

alias:
fileURLToPath 输出的是基于根路径的路径,最后在vite中会加上盘符,去E:\src访问了(很好奇为什么linux下不会去直接找根目录的/src)
"@": fileURLToPath(new URL("/src", import.meta.url)),
"@console": fileURLToPath(new URL("/console-src", import.meta.url)),
"@uc": fileURLToPath(new URL("/uc-src", import.meta.url)),

相关日志输出

D:\nodejs\node_global\pnpm.cmd run dev

> @halo-dev/console@2.11.0 dev E:\halo\halo\console
> run-p dev:console dev:uc


> @halo-dev/console@2.11.0 dev:console E:\halo\halo\console
> vite --host --config ./vite.config.ts


> @halo-dev/console@2.11.0 dev:uc E:\halo\halo\console
> vite --host --config ./vite.uc.config.ts


 ERROR  failed to load config from E:\halo\halo\console\vite.config.ts                                                                 15:39:25  


 ERROR  error when starting dev server:                                                                                                15:39:25  
TypeError [ERR_INVALID_URL_SCHEME]: The URL must be of scheme file
    at new NodeError (node:internal/errors:405:5)
    at fileURLToPath (node:internal/url:1436:11)
    at createViteConfig (E:\halo\halo\console\vite.config.ts:194:44)
    at vite_config_default (E:\halo\halo\console\vite.config.ts:205:10)
    at loadConfigFromFile (file:///E:/halo/halo/console/node_modules/.pnpm/vite@4.2.3_@types+node@18.13.0_sass@1.60.0/node_modules/vite/dist/node
/chunks/dep-f2591f42.js:63855:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async resolveConfig (file:///E:/halo/halo/console/node_modules/.pnpm/vite@4.2.3_@types+node@18.13.0_sass@1.60.0/node_modules/vite/dist/nod
e/chunks/dep-f2591f42.js:63466:28)
    at async createServer (file:///E:/halo/halo/console/node_modules/.pnpm/vite@4.2.3_@types+node@18.13.0_sass@1.60.0/node_modules/vite/dist/node
/chunks/dep-f2591f42.js:62752:20)
    at async CAC.<anonymous> (file:///E:/halo/halo/console/node_modules/.pnpm/vite@4.2.3_@types+node@18.13.0_sass@1.60.0/node_modules/vite/dist/n
ode/cli.js:734:24)

 ELIFECYCLE  Command failed with exit code 1.

 ERROR  failed to load config from E:\halo\halo\console\vite.uc.config.ts                                                              15:39:25  


 ERROR  error when starting dev server:                                                                                                15:39:25  
TypeError [ERR_INVALID_URL_SCHEME]: The URL must be of scheme file
    at new NodeError (node:internal/errors:405:5)
    at fileURLToPath (node:internal/url:1436:11)
    at createViteConfig (E:\halo\halo\console\vite.uc.config.ts:193:44)
    at vite_uc_config_default (E:\halo\halo\console\vite.uc.config.ts:203:10)
    at loadConfigFromFile (file:///E:/halo/halo/console/node_modules/.pnpm/vite@4.2.3_@types+node@18.13.0_sass@1.60.0/node_modules/vite/dist/node
/chunks/dep-f2591f42.js:63855:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async resolveConfig (file:///E:/halo/halo/console/node_modules/.pnpm/vite@4.2.3_@types+node@18.13.0_sass@1.60.0/node_modules/vite/dist/nod
e/chunks/dep-f2591f42.js:63466:28)
    at async createServer (file:///E:/halo/halo/console/node_modules/.pnpm/vite@4.2.3_@types+node@18.13.0_sass@1.60.0/node_modules/vite/dist/node
/chunks/dep-f2591f42.js:62752:20)
    at async CAC.<anonymous> (file:///E:/halo/halo/console/node_modules/.pnpm/vite@4.2.3_@types+node@18.13.0_sass@1.60.0/node_modules/vite/dist/n
ode/cli.js:734:24)

 ELIFECYCLE  Command failed with exit code 1.
ERROR: "dev:console" exited with 1.
 ELIFECYCLE  Command failed with exit code 1.

Process finished with exit code 1













D:\nodejs\node_global\pnpm.cmd run build
> @halo-dev/console@2.11.0 build E:\halo\halo\console
> run-s build:console build:uc
> @halo-dev/console@2.11.0 build:console E:\halo\halo\console
> vue-tsc --noEmit && vite build --config ./vite.config.ts   
vite v4.2.3 building for production...                                                                                                 15:44:49
 WARN  <script src="/console/assets/vue/vue.global.3286e1b2.js"> in "/index.html" can't be bundled without type="module" attribute     15:44:49


 WARN  <script src="/console/assets/vue-router/vue-router.global.3286e1b2.js"> in "/index.html" can't be bundled without type="module" attribute 


 WARN  <script src="/console/assets/vue-demi/vue-demi.3286e1b2.js"> in "/index.html" can't be bundled without type="module" attribute  15:44:49  


 WARN  <script src="/console/assets/vueuse/vueuse.shared.iife.3286e1b2.js"> in "/index.html" can't be bundled without type="module" attribute    


 WARN  <script src="/console/assets/vueuse/vueuse.core.iife.3286e1b2.js"> in "/index.html" can't be bundled without type="module" attribute      


 WARN  <script src="/console/assets/vueuse/vueuse.components.iife.3286e1b2.js"> in "/index.html" can't be bundled without type="module" attribute


 WARN  <script src="/console/assets/vueuse/vueuse.router.iife.3286e1b2.js"> in "/index.html" can't be bundled without type="module" attribute    


 WARN  <script src="/console/assets/components/halo-components.iife.3286e1b2.js"> in "/index.html" can't be bundled without type="module" attribu
te


 WARN  <script src="/console/assets/console-shared/halo-console-shared.iife.3286e1b2.js"> in "/index.html" can't be bundled without type="module"
 attribute

transforming (3) console-src\main.ts
 WARN  Browserslist: caniuse-lite is outdated. Please run:                                                                             15:44:50  
  npx update-browserslist-db@latest
  Why you should do it regularly: https://github.com/browserslist/update-db#readme

✓ 6 modules transformed.                                                                                                               15:44:51  

 ERROR  [vite-plugin-pwa:build] Could not load E:\src/utils/api-client (imported by console-src/main.ts): ENOENT: no such file or directory, open
 'E:\src\utils\api-client'


 ERROR  error during build:                                                                                                            15:44:51  
Error: Could not load E:\src/utils/api-client (imported by console-src/main.ts): ENOENT: no such file or directory, open 'E:\src\utils\api-client
'

 ELIFECYCLE  Command failed with exit code 1.
ERROR: "build:console" exited with 1.
 ELIFECYCLE  Command failed with exit code 1.

附加信息

No response

@ruibaby
Copy link
Member

ruibaby commented Nov 18, 2023

感谢反馈!

/assign
/kind bug
/area console

@f2c-ci-robot f2c-ci-robot bot added kind/bug Categorizes issue or PR as related to a bug. area/console Issues or PRs related to the Halo Console labels Nov 18, 2023
f2c-ci-robot bot pushed a commit that referenced this issue Nov 20, 2023
#### What type of PR is this?

/kind bug
/area console
/milestone 2.11.x

#### What this PR does / why we need it:

修复在 Windows 平台下无法正常启动 Console 服务以及无法正常编译的问题。

<img width="1124" alt="图片" src="https://github.com/halo-dev/halo/assets/21301288/55edd00a-8e71-437e-8889-0fe4a43bb40b">

#### Which issue(s) this PR fixes:

Fixes #4874

#### Special notes for your reviewer:

在 Windows 平台下测试 `pnpm dev` 和 `pnpm build`,检查是否能够正常运行。

#### Does this PR introduce a user-facing change?

```release-note
None
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/console Issues or PRs related to the Halo Console kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants