miniprogram-demo
miniprogram-demo copied to clipboard
现在什么情况,这个demo还能跑吗?
为什么我在根目录执行npm run init就报fatal: not a git repository (or any of the parent directories): .git,然后我跑去 git下载下来,就报Clone failed. Cannot clone submodules.,这怎么搞啊
可以跑,微信开发者工具版本:
- git clone
- npm run init
- npm install
- 开发者工具导入,工具->构建npm
- 依据错误提示把.ts后缀文件修改为.js
- 重新编译即可
my error
trigger step: npm run init
- when
npm run sync, no access to clone[email protected]:wechat-miniprogram/awesome-skyline.git
Please make sure you have the correct access rights
and the repository exists.
fatal: clone of '[email protected]:wechat-miniprogram/awesome-skyline.git' into submodule path 'C:/code/wechat/miniprogram-demo/miniprogram/packageSkylineExamples' failed
- when
npm i, unable to install
npm warn config production Use `--omit=dev` instead.
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: [email protected]
npm error Found: [email protected]
npm error node_modules/eslint
npm error dev eslint@"^8.57.1" from the root project
npm error
npm error Could not resolve dependency:
npm error peer eslint@"^5.0.0 || ^6.0.0 || ^7.0.0" from @typescript-eslint/[email protected]
npm error node_modules/@typescript-eslint/parser
npm error dev @typescript-eslint/parser@"^4.6.1" from the root project
npm error peer @typescript-eslint/parser@"^4.0.0" from @typescript-eslint/[email protected]
npm error node_modules/@typescript-eslint/eslint-plugin
npm error dev @typescript-eslint/eslint-plugin@"^4.6.1" from the root project
how to fix
It works, but a little extra step is needed to set up the following
pc environment:
- system: Windows 11
- node: 20
- change
.gitmodulesfile in.git/config(change url from SHH to HTTPS, cos u have no access)
// .git/config/.gitmodules
// url = [email protected]:wechat-miniprogram/awesome-skyline.git
url = https://github.com/wechat-miniprogram/awesome-skyline.git
- change
init scriptsinpackage.json(replace npm to yarn)
// "init": "npm run sync && cd cloudfunctions/ && npm i --production && cd ../miniprogram/ && npm i --production",
"init": "npm run sync && cd cloudfunctions/ && yarn install --production && cd ../miniprogram/ && yarn install --production",
这个错误跟 Node.js 的版本没有直接关系,主要是由于 依赖冲突(dependency conflict)导致的,npm 无法自动解析出一个兼容的依赖树。
💥 报错关键点:
你看到的错误是:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
它进一步说明了:
- 你的项目使用了
eslint@^8.57.1 - 但
@typescript-eslint/[email protected]和@typescript-eslint/[email protected]只兼容eslint@^5.0.0 || ^6.0.0 || ^7.0.0 - 两者不兼容,安装失败
✅ 修复方法
方法 1:使用 --legacy-peer-deps
这个是最快的方式,让 npm 忽略 peer 依赖冲突,强制安装:
npm install --legacy-peer-deps
方法 2:升级 @typescript-eslint 依赖版本
你当前用的是 @typescript-eslint/*@4.33.0,这个版本太老了,不支持 eslint@8。可以把它们升级到和 eslint@8 兼容的版本(比如 ^6.0.0):
package.json 示例修改:
"devDependencies": {
"eslint": "^8.57.1",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0"
}
然后再重新安装:
npm install
方法 3:降级 eslint 到兼容版本
如果你不想动 @typescript-eslint 的版本,那就把 eslint 降级到 ^7.x:
npm install eslint@^7.0.0
🔍 建议检查 Node/NPM 版本(非核心问题,但建议统一)
你可以查看当前版本:
node -v
npm -v
建议使用 LTS 版本,比如 Node.js v18.x + npm v9.x。
需要我帮你检查 package.json 配置是否合理的话,也可以发上来看看~
现在出现的新错误是:
Host key verification failed.
fatal: Could not read from remote repository.
这是因为你使用的是SSH方式来克隆子模块,但本机的SSH配置存在问题,可能的原因包括:
原因分析:
- 未配置或未正确配置Git的SSH Key。
- 未添加SSH公钥到GitHub账户中。
- 首次连接到GitHub的host校验失败。
解决方案:
你可以选择以下任一方式来解决此问题:
方法一:切换为 HTTPS 方式(简单推荐)
修改子模块配置,使用HTTPS协议来拉取代码。
修改你的 .gitmodules 文件,把:
[email protected]:wechat-miniprogram/awesome-skyline.git
改为:
https://github.com/wechat-miniprogram/awesome-skyline.git
修改完后,再运行:
git submodule sync
git submodule update --init --recursive
方法二:配置 SSH 密钥认证(推荐熟悉 SSH 用户)
步骤:
- 检查本地SSH密钥(Git Bash 或 cmd):
cat ~/.ssh/id_rsa.pub
如果没有任何内容输出,表示你本地尚未创建SSH Key。你需要创建一个SSH Key:
- 创建SSH Key:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
- 添加 SSH 公钥到 GitHub:
- 登录你的 GitHub 账号。
- 进入
Settings → SSH and GPG keys。 - 点击
New SSH key,将你刚刚生成的公钥(~/.ssh/id_rsa.pub的内容)复制粘贴进去并保存。
- 测试SSH连接:
ssh -T [email protected]
- 首次连接会提示你是否信任该主机,输入
yes并确认。
如果出现类似下面的内容,说明成功:
Hi YourUsername! You've successfully authenticated...
此时再运行:
git submodule update --init --recursive
推荐方案:
- 如果你是想快速解决问题,请选方法一(HTTPS)。
- 如果你以后要经常使用Git,建议按方法二配置一次SSH Key,以后就不用再反复输入账号密码。
你可以根据自己的情况,选择适合的方案进行操作。