简体   繁体   English

无法开始新的 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

I am just getting started with Expo and trying to create my first project.我刚刚开始使用 Expo 并尝试创建我的第一个项目。 I installed Node.js (v14.0.0) via Homebrew , and installed installed expo-cli using npm by running the following command as mentioned in the Expo quick start guide :我通过Homebrew安装了 Node.js (v14.0.0),并通过运行 Expo快速入门指南中提到的以下命令,使用npm安装了已安装expo-cli

# Install the command line tools
npm install --global expo-cli

# Create a new project
expo init my-project

However, I received an error when running the expo init my-project command which looks like this:但是,我在运行expo init my-project命令时收到如下错误:

ERROR: Node.js version 14.0.0 is no longer supported.错误:不再支持 Node.js 版本 14.0.0。

expo-cli supports following Node.js versions: expo-cli 支持以下 Node.js 版本:

  • >=10.13.0 <11.0.0 (Active LTS) >=10.13.0 <11.0.0(活跃的 LTS)

  • >=12.0.0 <13.0.0 (Active LTS) >=12.0.0 <13.0.0(活跃的 LTS)

  • >=13.0.0 <14.0.0 (Current Release) >=13.0.0 <14.0.0(当前版本)

I tried running expo , expo-cli , expo diagnostics , and I keep getting the same error message every time.我尝试运行expoexpo-cliexpo diagnostics ,但每次都收到相同的错误消息。 I am practically unable to run expo command .我几乎无法运行expo命令

I checked Node.js release notes , and turns out Node.js has recently been bumped to version 14.x.我检查了 Node.js发行说明,发现 Node.js 最近升级到了 14.x 版。

Can someone familiar with Expo development and release timelines help with what should be the recommend approach here out of the following two?熟悉 Expo 开发和发布时间表的人可以帮助解决以下两种推荐方法吗?

  1. Downgrade to an older stable and Expo supported version of Node.js.降级到较旧的稳定版和 Expo 支持的 Node.js 版本。

  2. Wait for an update to Expo (only if an update to Expo is in pipeline to be released soon).等待 Expo 的更新(仅当 Expo 的更新即将发布时)。

I am using a Mac running the current latest public release of macOS Catalina version 10.15.4 (19E287).我使用的 Mac 运行当前最新公开发布的 macOS Catalina 版本 10.15.4 (19E287)。

The best solution is to downgrade to a node version supported by expo-cli using brew .最好的解决方案是使用brew降级到expo-cli支持的node版本。
Just run the following commands:只需运行以下命令:

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

And you're done!你完成了! expo-cli is back on track! expo-cli重回正轨!


Explanation:解释:

#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

Notes:笔记:

  • as these commands get the highest alternative node version available with brew dynamically installed, it would work in the future too.由于这些命令获得了动态安装的brew可用的最高替代node版本,因此它将来也可以使用。
  • a pull request fixing the current issue has been merged in the official expo-cli repo and thus should soon be available.解决当前问题的拉取请求已合并到官方expo-cli库中,因此应该很快可用。

Working @ May 2020工作@ 2020年5月

$ brew uninstall node  --ignore-dependencies node
$ brew install node@12
$ brew link --force --overwrite node@12

You should use Node 12.js version.您应该使用 Node 12.js 版本。 Expo takes some time to support new releases of Node. Expo 需要一些时间来支持新版本的 Node。 So the best bet is to downgrade your Node to version 12 which is currently supported.所以最好的办法是将您的节点降级到当前支持的版本 12。 I had similar issue recently with backward compatibility.我最近在向后兼容性方面遇到了类似的问题。 See these comments.看到这些评论。 Stackoverflow堆栈溢出

Same problem today, I'm using nvm and selected node version is v13.7.0.今天同样的问题,我正在使用 nvm 并且选择的节点版本是 v13.7.0。 The solution was to upgrade expo-cli to latest version (expo-cli@3.20.9).解决方案是将 expo-cli 升级到最新版本 (expo-cli@3.20.9)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM