Mac: Expo 正在更新但不工作并解决过时的包

Mac: Expo being updated but not working and resolving out-of-date packages

我的 expo-cli 在 Windows 上运行良好,项目已初始化并且 运行ning 我希望能够在这台机器上完成。但是,在 Mac 上,它一直说包正在更新,但是当我尝试 运行ning expo init 或全局的 expo 命令时,它不起作用:

/Users/daggerpov/.npm/bin/expo -> /Users/daggerpov/.npm/lib/node_modules/expo-cli/bin/expo.js
/Users/daggerpov/.npm/bin/expo-cli -> /Users/daggerpov/.npm/lib/node_modules/expo-cli/bin/expo.js
+ expo-cli@4.11.0
updated 2 packages in 94.007s
daggerpov@Daniels-MBP ~ % expo
zsh: command not found: expo

此外,我收到了一堆弃用警告,但我听说通过 npm 安装它是预期的,不过这里是完整的输出:

daggerpov@Daniels-MBP ~ % npm install -g expo-cli
npm WARN deprecated graphql-tools@3.0.0: This package has been deprecated and now it only exports makeExecutableSchema.\nAnd it will no longer receive updates.\nWe recommend you to migrate to scoped packages such as @graphql-tools/schema, @graphql-tools/utils and etc.\nCheck out https://www.graphql-tools.com to learn what package you should use instead
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated uuid@3.0.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
/Users/daggerpov/.npm/bin/expo -> /Users/daggerpov/.npm/lib/node_modules/expo-cli/bin/expo.js
/Users/daggerpov/.npm/bin/expo-cli -> /Users/daggerpov/.npm/lib/node_modules/expo-cli/bin/expo.js
+ expo-cli@4.11.0
updated 2 packages in 94.007s

我为解决无法使用 expo 命令的问题所做的工作是:

daggerpov@Daniels-MBP ~ % npm install expo-cli global
(just some of the same deprecation warnings)
npm WARN checkPermissions Missing write access to /Users/daggerpov/node_modules/expo-cli
npm WARN daggerpov@1.0.0 No description
npm WARN daggerpov@1.0.0 No repository field.

npm ERR! code ELOOP
npm ERR! syscall access
npm ERR! path /Users/daggerpov/node_modules/expo-cli
npm ERR! errno -62
npm ERR! ELOOP: too many symbolic links encountered, access '/Users/daggerpov/node_modules/expo-cli'

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/daggerpov/.npm/_logs/2021-09-10T06_57_31_944Z-debug.log

也许因为我的节点版本比 LTS 更新一点,所以它可能会带来问题?

daggerpov@Daniels-MBP ~ % node --version
v14.8.0
daggerpov@Daniels-MBP ~ % npm --version
6.14.8

更新:我已将我的节点版本更改为 LTS,并确保 usr/local/bin 在 $PATH 中,但这并没有解决问题。

daggerpov@Daniels-MBP ~ % echo $PATH
/Users/daggerpov/.pyenv/shims:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
daggerpov@Daniels-MBP ~ % node --version
v14.17.6

我已经按照 this issue 中的概述安装了 nvm:然后我 运行 nvm install node 并且它给了我 v16.9.0。然后,我 运行 npm install --global expo-cli 和以前一样,现在 expo 命令运行正常。

重要说明: expo 命令只能在使用 nvm install node 命令后立即工作,所以当我去 VSC 时,我必须在每次会话之前使用它。我将尝试找到解决此问题的方法并相应地编辑此答案。因此, 是您使用 nvm 配置节点版本并保留它的方式。就个人而言,我做了 nvm use 16.9.0 然后当我检查我的节点版本时它保存了。