Cloud functionsのNode.jsを12→16にしたらデプロイ失敗した件

こんにちは。
株式会社エス・スリーのスタッフです。

本日は、先日Cloud Functionsのnode.jsを12から16に変更した際のトラブルについて。
デプロイ時にビルドに失敗したようなエラーが出ます。

=== Deploying to '●●'...

i deploying functions
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
+ functions: required API cloudbuild.googleapis.com is enabled
+ functions: required API cloudfunctions.googleapis.com is enabled
i functions: preparing codebase default for deployment
i functions: preparing functions directory for uploading...
i functions: packaged c:\node_works\StriveNippou\functions (5.88 MB) for uploading
i functions: ensuring required API cloudscheduler.googleapis.com is enabled...
+ functions: required API cloudscheduler.googleapis.com is enabled
+ functions: functions folder uploaded successfully
i functions: updating Node.js 16 function updateUser(us-central1)...
Build failed: ...8::internal::PerformCastCheck(T*)':
npm ERR! /www-data-home/.cache/node-gyp/16.15.0/include/node/v8-internal.h:492:38: error: 'remove_cv_t' is not a member of 'std'
npm ERR! !std::is_same>::value>::Perform(data);
npm ERR! ^~~~~~~~~~~
npm ERR! /www-data-home/.cache/node-gyp/16.15.0/include/node/v8-internal.h:492:38: note: suggested alternative: 'remove_cv'
npm ERR! !std::is_same>::value>::Perform(data);
npm ERR! ^~~~~~~~~~~
npm ERR! remove_cv
npm ERR! /www-data-home/.cache/node-gyp/16.15.0/include/node/v8-internal.h:492:38: error: 'remove_cv_t' is not a member of 'std'
npm ERR! /www-data-home/.cache/node-gyp/16.15.0/include/node/v8-internal.h:492:38: note: suggested alternative: 'remove_cv'
npm ERR! !std::is_same>::value>::Perform(data);
npm ERR! ^~~~~~~~~~~
npm ERR! remove_cv
npm ERR! /www-data-home/.cache/node-gyp/16.15.0/include/node/v8-internal.h:492:50: error: template argument 2 is invalid
npm ERR! !std::is_same>::value>::Perform(data);
npm ERR! ^
npm ERR! /www-data-home/.cache/node-gyp/16.15.0/include/node/v8-internal.h:492:63: error: '::Perform' has not been declared
npm ERR! !std::is_same>::value>::Perform(data);
npm ERR! ^~~~~~~
npm ERR! /www-data-home/.cache/node-gyp/16.15.0/include/node/v8-internal.h:492:63: note: suggested alternative: 'perror'
npm ERR! !std::is_same>::value>::Perform(data);
npm ERR! ^~~~~~~
npm ERR! perror
npm ERR! At global scope:
npm ERR! cc1plus: warning: unrecognized command line option '-Wno-cast-function-type'
npm ERR! make: *** [Release/obj.target/sharp/src/common.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.onExit (/workspace/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 5.10.0-14-cloud-amd64
npm ERR! gyp ERR! command "/usr/bin/node" "/workspace/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /workspace/node_modules/sharp
npm ERR! gyp ERR! node -v v16.15.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok

最初は上部のCらしきエラーに着目してしまい、?となっていました。
しかし結局は最後から4行目、sharpのライブラリとの互換性の問題で、sharpを最新版にすることで解決しました。

npm install sharp@latest

似たようなエラーが出た方のご参考になれば幸いです。
それにしても、ついこの間にnodeを10から12にした気がするのに、今度はまた16にしないといけないのか…と軽くショックを受けました。
しかも、functions自体がv1からv2へ変わりそうな感じですね。(まだv2はプレビュー)
HTTP関数が60分と、だいぶ大量のデータも処理できるようになりそうです。

最後までお読みいただき、ありがとうございます。

よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!

この記事を書いた人

目次