修改Vercel构建时使用的Node版本

Vercel Node 版本的说明

官方参考:意思是设置了 engines.node 后,如果与项目的 node 版本不一致,则使用前者

Defining the node property inside engines of a package.json file will override the selection made in the Project Settings and print a Build Step warning if the version does not match. Please avoid greater than ranges, such as >14.x or >=14, because this will match semver major versions of Node.js once available which contains breaking changes.
For example, the range >16.2.0 would match the versions 16.2.5, 16.3.0, and 18.0.0.

通过 package.json 修改 node 版本

在 package.json 中通过 engines.node 指定 node 版本

{
  ....
  "engines": {
    "node": ">16.14.0 <17"
  },
  ...
}

在界面中修改项目的 Node 版本

注意:若使用 package.json 修改了 Node 版本,且与项目指定的版本不一致,则使用前者

参考:https://vercel.com/docs/concepts/functions/serverless-functions/runtimes/node-js#node.js-version

posted @ 2023-02-04 00:51  egu0o  阅读(790)  评论(1编辑  收藏  举报