收藏
回答

在云函数中使用got为什么总是提示 Error: Cannot find module 'got'?

在某个云函数目录下用npm安装了got,然后分别使用 “上传并部署:云端安装依赖和 “上传并部署:所有文件” 试过,都提示Error: Cannot find module 'got',然而在package.json的依赖项中有got,删除云函数后再次新建和部署也没用,到底是哪里出了问题呢?

下面是控制台的提示信息:

VM1480 WAService.js:2 Unhandled promise rejection Error: cloud.callFunction:fail Error: errCode: -504002 functions execute fail | errMsg: Runtime.ImportModuleError: Error: Cannot find module 'got'

    at Object.module.exports.load (:21403/var/runtime/node10/UserFunction.js:35)

    at Runtime.handleOnce (:21403/var/runtime/node10/Runtime.engine.js:98)

    at Timeout.setTimeout [as _onTimeout] (:21403/var/runtime/node10/Runtime.engine.js:55)

    at ontimeout (:21403/appservice/timers.js:436)

    at tryOnTimeout (:21403/appservice/timers.js:300)

    at listOnTimeout (:21403/appservice/timers.js:263)

    at Timer.processTimers (:21403/appservice/timers.js:223) (callId: 1645266750652-0.5721262603740986) (trace: 18:32:30 start->18:32:37 system error (Error: errCode: -504002 functions execute fail | errMsg: Runtime.ImportModuleError: Error: Cannot find module 'got'

    at Object.module.exports.load (:21403/var/runtime/node10/UserFunction.js:35)

    at Runtime.handleOnce (:21403/var/runtime/node10/Runtime.engine.js:98)

    at Timeout.setTimeout [as _onTimeout] (:21403/var/runtime/node10/Runtime.engine.js:55)

    at ontimeout (:21403/appservice/timers.js:436)

    at tryOnTimeout (:21403/appservice/timers.js:300)

    at listOnTimeout (:21403/appservice/timers.js:263)

    at Timer.processTimers (:21403/appservice/timers.js:223)), abort)

    at I (VM1480 WAService.js:2)

    at VM1480 WAService.js:2

    at VM1480 WAService.js:2

    at n (VM1480 WAService.js:2)(env: Windows,mp,1.05.2107221; lib: 2.21.2)

回答关注问题邀请回答
收藏

1 个回答

  • 九零
    九零
    2022-02-19

    好了好了,降低got的版本就可以了

    2022-02-19
    有用 1
    回复 2
    • Today
      Today
      2022-06-20
      降到哪一版本呢?
      2022-06-20
      回复
    • Today
      Today
      2022-06-20
      已解决
      npm i got@9
      2022-06-20
      3
      回复
登录 后发表内容