こんにちは。もぐめっとです。
今日はcloud functionsをデプロイしようとしたらこんな事言われたので軽くメモをしておきます。
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.
原因
ターミナルのログ見てもさっぱりわからないのでcloud functions側のログを見たら答えが書いてありました。
Detailed stack trace: Error: Cannot find module 'child-process-promise'
Did you list all required modules in the package.json dependencies?
child-process-promiseがdevDependenciesに入っているのがダメだったみたいですね。
素直にdependenciesに入れ直したら治りました。
npm i child-process-promise --save
教訓
エラーログはちゃんと読もう!