我把vant的源码下载到本地了,想着运行起来,但是总是报错 #9838
-
What problem does this feature solve?vant源码本地运行启动 What does the proposed API look like?TypeError: Cannot destructure property 'nav' of 'vantConfig.site' as it is undefined. 在控制台执行的时候报这样的错误,我更换了node版本,删除node_modules文件等操作后仍然运行不起来。各位都是如何运行启动的,麻烦指点下 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
我也遇到这个问题了,求解 |
Beta Was this translation helpful? Give feedback.
-
可以参考下 https://vant-contrib.gitee.io/vant/v3/#/zh-CN/contribution#ben-di-kai-fa |
Beta Was this translation helpful? Give feedback.
-
我也遇到相同问题,下载的是 dev 分支,按照错误日志提示,找到了可能出错的脚本代码,加了一句输出错误日志代码。 // packages/vant-cli/lib/common/constant.js
sync function getVantConfigAsync() {
const require = createRequire(import.meta.url);
delete require.cache[VANT_CONFIG_FILE];
try {
return (await import(VANT_CONFIG_FILE)).default;
}
catch (err) {
// 自己加的
console.error(err)
return {};
}
}
const vantConfig = await getVantConfigAsync();
export function getVantConfig() {
return vantConfig;
} 运行
我的日常办公环境是 Windows 系统,绝对路径是不带 file 协议且以磁盘盘符开头;按照这个提示,我又在 Linux(CentOS 7.6)上测试——项目运行是没问题的。 return (await import(pathToFileURL(VANT_CONFIG_FILE))).default; 再次执行 |
Beta Was this translation helpful? Give feedback.
我也遇到相同问题,下载的是 dev 分支,按照错误日志提示,找到了可能出错的脚本代码,加了一句输出错误日志代码。
运行
pnpm run dev
后在控制台看到了这个报错信息: