运行“expo start”时显示错误消息(错误:UnhandledPromiseRejectionWarning)

问题描述 投票:0回答:2

我刚刚将我的 Expo 项目克隆到我的新 MacBook 上。我已经使用yarn安装了软件包和expo global,但没有运气运行

expo start
。错误信息如下:

(node:39137) UnhandledPromiseRejectionWarning: /Users/hurraychak/.config/yarn/global/node_modules/@expo/cli/build/src/api/rest/client.js:28
    name = "ApiV2Error";
         ^

SyntaxError: Unexpected token =
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/Users/hurraychak/.config/yarn/global/node_modules/@expo/cli/build/src/api/getExpoGoIntermediateCertificate.js:7:15)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
(node:39137) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:39137) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:39137) UnhandledPromiseRejectionWarning: /Users/hurraychak/.config/yarn/global/node_modules/@expo/cli/build/src/api/rest/client.js:28
    name = "ApiV2Error";
         ^

SyntaxError: Unexpected token =
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/Users/hurraychak/.config/yarn/global/node_modules/@expo/cli/build/src/api/getExpoGoIntermediateCertificate.js:7:15)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
(node:39137) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 7)

我在互联网上找不到任何人讨论此错误。我发现运行时显示此错误消息

expo
。请帮我解决这个问题,谢谢!

react-native expo
2个回答
0
投票

我已通过运行

nvm use18
使用最新的节点版本解决了该问题。

之前,我尝试通过命令和下载两种方式升级node,但系统仍然使用10.xx.xx版本的node,而我没有意识到这一点。


0
投票

HurrayChak 的上述答案基本上对我有用,但最初我使用 WebStorm 时感到困惑。

我需要转到“设置”->“语言和框架”->“Node.js”并指向那里的正确节点版本。从 WebStorm UI 运行 package.json 脚本时,在 WebStorm 终端窗口中运行 nvm use 18 不起作用。

© www.soinside.com 2019 - 2024. All rights reserved.