无法开始新的 Expo 项目 | Node.js 不再支持版本 14.0.0
Unable to get started with a new Expo project | Node.js version 14.0.0 is no longer supported
我刚刚开始使用 Expo 并尝试创建我的第一个项目。我通过 Homebrew, and installed installed expo-cli
using npm
by running the following command as mentioned in the Expo quick start guide:
安装了 Node.js (v14.0.0)
# Install the command line tools
npm install --global expo-cli
# Create a new project
expo init my-project
但是,当 运行 执行 expo init my-project
命令时,我收到一个错误,如下所示:
ERROR: Node.js version 14.0.0 is no longer supported.
expo-cli supports following Node.js versions:
>=10.13.0 <11.0.0 (Active LTS)
>=12.0.0 <13.0.0 (Active LTS)
>=13.0.0 <14.0.0 (Current Release)
我尝试了 运行ning expo
、expo-cli
、expo diagnostics
,但每次都收到相同的错误消息。 我几乎无法运行 expo
命令.
我检查了 Node.js release notes,结果发现 Node.js 最近升级到版本 14.x。
熟悉 Expo 开发和发布时间表的人能否提供以下两种推荐方法中的哪一种?
降级到 Node.js.
的较旧稳定版本和 Expo 支持版本
等待 Expo 的更新(仅当 Expo 的更新正在准备中并即将发布时)。
我正在使用 Mac 运行 当前最新 public 版本的 macOS Catalina 版本 10.15.4 (19E287)。
最好的解决方案是使用 brew
.
降级到 expo-cli
支持的 node
版本
只需 运行 以下命令:
brew unlink node
brew install ${MAX_ALT_NODE=$(brew search node | grep node@ | sort -rn | head -n 1)}
brew link --overwrite --force $MAX_ALT_NODE
大功告成! expo-cli
重回正轨!
解释:
#unlink current node version so we can install another version
brew unlink node
#install the highest alternative node version available with `brew`
brew install ${MAX_ALT_NODE=$(brew search node | grep node@ | sort -rn | head -n 1)}
#force link this version to use it instead of default node version
brew link --overwrite --force $MAX_ALT_NODE
备注:
- 因为这些命令获得了最高的替代
node
版本,并且 brew
是动态安装的,它在未来也可以使用。
- 解决当前问题的 pull request 已合并到官方
expo-cli
存储库中,因此应该很快可用。
您应该使用 Node 12.js 版本。 Expo 需要一些时间来支持 Node.js 的新版本。所以最好的办法是将您的节点降级到当前支持的版本 12。我最近在向后兼容性方面遇到了类似的问题。查看这些评论。
2020 年 5 月工作
$ brew uninstall node --ignore-dependencies node
$ brew install node@12
$ brew link --force --overwrite node@12
今天同样的问题,我正在使用 nvm 并且选择的节点版本是 v13.7.0。
解决方案是将 expo-cli 升级到最新版本 (expo-cli@3.20.9)。
我刚刚开始使用 Expo 并尝试创建我的第一个项目。我通过 Homebrew, and installed installed expo-cli
using npm
by running the following command as mentioned in the Expo quick start guide:
# Install the command line tools
npm install --global expo-cli
# Create a new project
expo init my-project
但是,当 运行 执行 expo init my-project
命令时,我收到一个错误,如下所示:
ERROR: Node.js version 14.0.0 is no longer supported.
expo-cli supports following Node.js versions:
>=10.13.0 <11.0.0 (Active LTS)
>=12.0.0 <13.0.0 (Active LTS)
>=13.0.0 <14.0.0 (Current Release)
我尝试了 运行ning expo
、expo-cli
、expo diagnostics
,但每次都收到相同的错误消息。 我几乎无法运行 expo
命令.
我检查了 Node.js release notes,结果发现 Node.js 最近升级到版本 14.x。
熟悉 Expo 开发和发布时间表的人能否提供以下两种推荐方法中的哪一种?
降级到 Node.js.
的较旧稳定版本和 Expo 支持版本
等待 Expo 的更新(仅当 Expo 的更新正在准备中并即将发布时)。
我正在使用 Mac 运行 当前最新 public 版本的 macOS Catalina 版本 10.15.4 (19E287)。
最好的解决方案是使用 brew
.
降级到 expo-cli
支持的 node
版本
只需 运行 以下命令:
brew unlink node
brew install ${MAX_ALT_NODE=$(brew search node | grep node@ | sort -rn | head -n 1)}
brew link --overwrite --force $MAX_ALT_NODE
大功告成! expo-cli
重回正轨!
解释:
#unlink current node version so we can install another version
brew unlink node
#install the highest alternative node version available with `brew`
brew install ${MAX_ALT_NODE=$(brew search node | grep node@ | sort -rn | head -n 1)}
#force link this version to use it instead of default node version
brew link --overwrite --force $MAX_ALT_NODE
备注:
- 因为这些命令获得了最高的替代
node
版本,并且brew
是动态安装的,它在未来也可以使用。 - 解决当前问题的 pull request 已合并到官方
expo-cli
存储库中,因此应该很快可用。
您应该使用 Node 12.js 版本。 Expo 需要一些时间来支持 Node.js 的新版本。所以最好的办法是将您的节点降级到当前支持的版本 12。我最近在向后兼容性方面遇到了类似的问题。查看这些评论。
2020 年 5 月工作
$ brew uninstall node --ignore-dependencies node
$ brew install node@12
$ brew link --force --overwrite node@12
今天同样的问题,我正在使用 nvm 并且选择的节点版本是 v13.7.0。 解决方案是将 expo-cli 升级到最新版本 (expo-cli@3.20.9)。