fix(window运行): 添加unconfig覆盖配置,解决windows 下高版本nodejs运行失败

This commit is contained in:
feige996
2025-09-30 16:52:20 +08:00
parent 2fac5c59e1
commit 7e58ff1b76
2 changed files with 11 additions and 31 deletions

View File

@@ -36,7 +36,7 @@
"dev:app-android": "uni -p app-android",
"dev:app-ios": "uni -p app-ios",
"dev:custom": "uni -p",
"dev": "node --experimental-loader ./scripts/window-path-loader.js node_modules/@dcloudio/vite-plugin-uni/bin/uni.js",
"dev": "uni",
"dev:test": "uni --mode test",
"dev:prod": "uni --mode production",
"dev:h5": "uni",
@@ -172,8 +172,17 @@
"vite-plugin-restart": "^1.0.0",
"vue-tsc": "^3.0.6"
},
"pnpm": {
"overrides": {
"unconfig": "7.3.2"
}
},
"overrides": {
"unconfig": "7.3.2"
},
"resolutions": {
"bin-wrapper": "npm:bin-wrapper-china"
"bin-wrapper": "npm:bin-wrapper-china",
"unconfig": "7.3.2"
},
"lint-staged": {
"*": "eslint --fix"

View File

@@ -1,29 +0,0 @@
// fix: https://github.com/unibest-tech/unibest/issues/219
// Windows path loader for Node.js ESM
// This loader converts Windows absolute paths to file:// URLs
import { pathToFileURL } from 'node:url'
/**
* Resolve hook for ESM loader
* Converts Windows absolute paths to file:// URLs
*/
export function resolve(specifier, context, defaultResolve) {
// Check if this is a Windows absolute path (starts with drive letter like C:)
if (specifier.match(/^[a-z]:\\/i) || specifier.match(/^[a-z]:\//i)) {
// Convert Windows path to file:// URL
const fileUrl = pathToFileURL(specifier).href
return defaultResolve(fileUrl, context, defaultResolve)
}
// For all other specifiers, use the default resolve
return defaultResolve(specifier, context, defaultResolve)
}
/**
* Load hook for ESM loader
*/
export function load(url, context, defaultLoad) {
return defaultLoad(url, context, defaultLoad)
}