Skip to content

现在什么情况,这个demo还能跑吗? #161

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

Open
qq921124136 opened this issue Feb 28, 2025 · 4 comments
Open

现在什么情况,这个demo还能跑吗? #161

qq921124136 opened this issue Feb 28, 2025 · 4 comments

Comments

@qq921124136
Copy link

为什么我在根目录执行npm run init就报fatal: not a git repository (or any of the parent directories): .git,然后我跑去 git下载下来,就报Clone failed.
Cannot clone submodules.,这怎么搞啊

@qq921124136 qq921124136 changed the title 现在什么情况 现在什么情况,这个demo还能跑吗? Feb 28, 2025
@Torboxin
Copy link

可以跑,微信开发者工具版本:
Image

  1. git clone
  2. npm run init
  3. npm install
  4. 开发者工具导入,工具->构建npm
  5. 依据错误提示把.ts后缀文件修改为.js
  6. 重新编译即可

@OldKwan
Copy link

OldKwan commented Apr 3, 2025

my error

trigger step: npm run init

  1. 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 'git@github.com:wechat-miniprogram/awesome-skyline.git' into submodule path 'C:/code/wechat/miniprogram-demo/miniprogram/packageSkylineExamples' failed
  1. 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: miniprogram-demo@1.0.0
npm error Found: eslint@8.57.1
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/parser@4.33.0
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/eslint-plugin@4.33.0
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
  1. change .gitmodules file 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
  1. change init scripts in package.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",

@Z863058
Copy link

Z863058 commented Apr 6, 2025

这个错误跟 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 配置是否合理的话,也可以发上来看看~

@Z863058
Copy link

Z863058 commented Apr 7, 2025

现在出现的新错误是:

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 用户)

步骤:

  1. 检查本地SSH密钥(Git Bash 或 cmd):
cat ~/.ssh/id_rsa.pub

如果没有任何内容输出,表示你本地尚未创建SSH Key。你需要创建一个SSH Key:

  1. 创建SSH Key:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
  1. 添加 SSH 公钥到 GitHub:
  • 登录你的 GitHub 账号。
  • 进入 Settings → SSH and GPG keys
  • 点击 New SSH key,将你刚刚生成的公钥(~/.ssh/id_rsa.pub的内容)复制粘贴进去并保存。
  1. 测试SSH连接:
  • 首次连接会提示你是否信任该主机,输入 yes 并确认。

如果出现类似下面的内容,说明成功:

Hi YourUsername! You've successfully authenticated...

此时再运行:

git submodule update --init --recursive

推荐方案:

  • 如果你是想快速解决问题,请选方法一(HTTPS)。
  • 如果你以后要经常使用Git,建议按方法二配置一次SSH Key,以后就不用再反复输入账号密码。

你可以根据自己的情况,选择适合的方案进行操作。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants