SDK 45 升级后 expo 启动失败 - 无法克隆 expo-keep-awake 功能

分享于2022年07月17日 expo ios node.js react-native 问答
【问题标题】:SDK 45 升级后 expo 启动失败 - 无法克隆 expo-keep-awake 功能(expo start failed after SDK 45 upgrade - expo-keep-awake function could not be cloned)
【发布时间】:2022-06-27 14:41:07
【问题描述】:

升级到 SDK 45 后,expo start 系统性地失败。

iOS Bundling failed 4230ms
node_modules/expo-keep-awake/build/index.js: function (path) {
          return fn.call(state, path, state);
        } could not be cloned.
Error: function (path) {
          return fn.call(state, path, state);
        } could not be cloned.
    at Object.serialize (node:v8:333:7)
    at _default (/home/prince/Documents/HandyTradie/fromBucket/htMobile/node_modules/@babel/core/lib/transformation/util/clone-deep.js:22:34)
    at normalizeFile (/home/prince/Documents/HandyTradie/fromBucket/htMobile/node_modules/@babel/core/lib/transformation/normalize-file.js:84:36)
    at normalizeFile.next ()
    at run (/home/prince/Documents/HandyTradie/fromBucket/htMobile/node_modules/@babel/core/lib/transformation/index.js:31:50)
    at run.next ()
    at /home/prince/Documents/HandyTradie/fromBucket/htMobile/node_modules/@babel/core/lib/transform-ast.js:26:41
    at Generator.next ()
    at evaluateSync (/home/prince/Documents/HandyTradie/fromBucket/htMobile/node_modules/@babel/core/node_modules/gensync/index.js:251:28)

请注意,我没有直接使用 expo-keep-awake,它没有链接在我的 package.json 中


【解决方案1】:

升级到 sdk 45 后我遇到了同样的问题。这种方式对我来说真的很管用

  • 删除 yarn.lock
  • 删除forder node_modules
  • 纱线安装