在某个云函数目录下用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)
好了好了,降低got的版本就可以了
npm i got@9