-
Notifications
You must be signed in to change notification settings - Fork 278
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
feat: specify a particular Node.js version using pnpm #1677
Open
gweesin
wants to merge
1
commit into
opentiny:dev
Choose a base branch
from
gweesin:feat/specify-node-version
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
shell-emulator=true | ||
auto-install-peers=true | ||
strict-peer-dependencies=false | ||
enable-pre-post-scripts=true | ||
enable-pre-post-scripts=true | ||
use-node-version=18.19.1 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你好,这个如果配置死了18.19.1,会让版本不匹配的用户重新下载nodejs,这样做不是很好哈吗,在内部下载会超时,但是还是感谢你的贡献哈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样做相当于以项目级别指定node版本,可以防止不同贡献者因为开发环境的node不同导致贡献仓库时有相关问题。
内部下载超时一般可以通过设置镜像解决,类似在 .npmrc 中添加指定淘宝镜像
node-mirror:release=https://npmmirror.com/mirrors/node/
我看华为云也有相关node生态的镜像,类似 cypress 的镜像
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我的理解是给用户相应的提示即可,不能迫使用户区下载nodejs,可以在package.json中指定下nodejs的最低版本的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
也就是说,这两者的作用域可以不同,比如说开发 tiny-vue 组件库统一使用 latest 版本,只要打出来的包兼容 node 12,使用 tiny-vue 组件库的用户使用 node 12 也可以正常运行。
相对应的,如果开发 tiny-vue 的开发者使用的是 node 12 而不是 latest,那么在运行 tiny-vue 源码时,自动下载源码所需的 node 版本理论上更合适,省去主动切换 node 版本。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
也就是说对于 tiny-vue 的开发者,把 node 环境也当做了依赖的一环,做到像安装 package.json 声明的依赖一样。
类似像 https://github.com/antfu/eslint-config/blob/c22689f8fc38f7c7a0e53b9fed7f359f36e5c7e4/package.json#L5
使用 corepack 并且指定 packageManager,还可以把包管理器当做依赖的一环,这样当 pnpm 和 node 版本都不同时,通过 corepack 自动安装项目所需 pnpm,通过 pnpm 自动安装项目所需 node,达到基本跟环境隔离的效果~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gweesin 有可能会出现一个问题,就是开发者没有搭梯子的话,执行
![image](https://private-user-images.githubusercontent.com/9566362/369249131-7fc25eae-1303-43a2-9418-1e9096b396b8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5MTI3ODEsIm5iZiI6MTczODkxMjQ4MSwicGF0aCI6Ii85NTY2MzYyLzM2OTI0OTEzMS03ZmMyNWVhZS0xMzAzLTQzYTItOTQxOC0xZTkwOTZiMzk2YjgucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDdUMDcxNDQxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MWFjZDQ4YzhiMzE5YTUzZTU0MzQ5OTQ5MDc5YjkyNmFiN2YzYTQzN2I0MmI3NzczN2Y5MDE2NTI5YTIwY2U0MyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.JPMtA_sET3pM5stsyapljd4bqD6HJ1NPG7_CF_ppXVY)
pnpm i
会报错。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是的,国内的话需要配置一次环境变量 COREPACK_NPM_REGISTRY=https://registry.npmmirror.com 指定淘宝镜像