6
2

More than 3 years have passed since last update.

M1 MacでAzure Functions Core Tools (Node.js版)が動かない件 (※ワークアラウンド)

Last updated at Posted at 2021-02-13

はじめに

LINE botをVS Codeで開発してAzure Functionsへデプロイするメモ (Node.js版)
を書いたのですが、M1 Macで実行したところローカル環境で動作しませんでした。

Start Debugging[F5]で実行するとgrpc関連でエラーが出力されます。

[2021-02-13T01:32:12.816Z] Debugger listening on ws://127.0.0.1:9229/f28a6986-09d1-4104-aae4-aa4ce42a3c82
[2021-02-13T01:32:12.824Z] For help, see: https://nodejs.org/en/docs/inspector
[2021-02-13T01:32:12.824Z] internal/modules/cjs/loader.js:883
[2021-02-13T01:32:12.824Z]   throw err;
[2021-02-13T01:32:12.824Z]   ^
[2021-02-13T01:32:12.825Z] Error: Cannot find module './Worker.js'
[2021-02-13T01:32:12.827Z] Expected directory: node-v83-darwin-arm64-unknown
[2021-02-13T01:32:12.827Z] Found: [node-v57-darwin-ia32-unknown, node-v57-darwin-x64-unknown, node-v57-linux-ia32-glibc, node-v57-linux-x64-glibc, node-v57-win32-ia32-unknown, node-v57-win32-x64-unknown, node-v64-darwin-ia32-unknown, node-v64-darwin-x64-unknown, node-v64-linux-ia32-glibc, node-v64-linux-x64-glibc, node-v64-win32-ia32-unknown, node-v64-win32-x64-unknown, node-v72-darwin-ia32-unknown, node-v72-darwin-x64-unknown, node-v72-linux-ia32-glibc, node-v72-linux-x64-glibc, node-v72-win32-ia32-unknown, node-v72-win32-x64-unknown, node-v83-darwin-ia32-unknown, node-v83-darwin-x64-unknown, node-v83-linux-ia32-glibc, node-v83-linux-x64-glibc, node-v83-win32-ia32-unknown, node-v83-win32-x64-unknown]
[2021-02-13T01:32:12.827Z] Exceeded language worker restart retry count for runtime:node. Shutting down and proactively recycling the Functions Host to recover
[2021-02-13T01:32:12.828Z] This problem can often be fixed by running "npm rebuild" on the current system
[2021-02-13T01:32:12.828Z] Original error: Cannot find module '/opt/homebrew/Cellar/azure-functions-core-tools@3/3.0.3284/workers/node/grpc/src/node/extension_binary/node-v83-darwin-arm64-unknown/grpc_node.node'
[2021-02-13T01:32:12.829Z] Require stack:
[2021-02-13T01:32:12.829Z] - /opt/homebrew/Cellar/azure-functions-core-tools@3/3.0.3284/workers/node/worker-bundle.js
[2021-02-13T01:32:12.829Z] - /opt/homebrew/Cellar/azure-functions-core-tools@3/3.0.3284/workers/node/dist/src/nodejsWorker.js
[2021-02-13T01:32:12.831Z] Require stack:
[2021-02-13T01:32:12.831Z] - /opt/homebrew/Cellar/azure-functions-core-tools@3/3.0.3284/workers/node/dist/src/nodejsWorker.js
[2021-02-13T01:32:12.831Z]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
[2021-02-13T01:32:12.831Z]     at Function.Module._load (internal/modules/cjs/loader.js:725:27)
[2021-02-13T01:32:12.831Z]     at Module.require (internal/modules/cjs/loader.js:952:19)
[2021-02-13T01:32:12.831Z]     at require (internal/modules/cjs/helpers.js:88:18)
[2021-02-13T01:32:12.869Z]     at Object.<anonymous> (/opt/homebrew/Cellar/azure-functions-core-tools@3/3.0.3284/workers/node/dist/src/nodejsWorker.js:45:14)
[2021-02-13T01:32:12.869Z]     at Module._compile (internal/modules/cjs/loader.js:1063:30)
[2021-02-13T01:32:12.869Z]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
[2021-02-13T01:32:12.869Z]     at Module.load (internal/modules/cjs/loader.js:928:32)
[2021-02-13T01:32:12.875Z]     at Function.Module._load (internal/modules/cjs/loader.js:769:14)
[2021-02-13T01:32:12.875Z]     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
[2021-02-13T01:32:12.875Z]   code: 'MODULE_NOT_FOUND',
[2021-02-13T01:32:12.875Z]   requireStack: [
[2021-02-13T01:32:12.875Z]     '/opt/homebrew/Cellar/azure-functions-core-tools@3/3.0.3284/workers/node/dist/src/nodejsWorker.js'
[2021-02-13T01:32:12.875Z]   ]
[2021-02-13T01:32:12.875Z] }

調べてみたところ本家でもissueが上がっていました。
https://github.com/Azure/azure-functions-core-tools/issues/2431

原因は出力内容からnode-v83-darwin-arm64-unknownが存在しないためです。
手動でgrpcモジュールをインストールしてリンクを貼れば動作しました。

% npm init -y
% npm install grpc
% ln -s `pwd`/node_modules/grpc/src/node/extension_binary/node-v83-darwin-arm64-unknown /opt/homebrew/Cellar/azure-functions-core-tools@3/3.0.3284/workers/node/grpc/src/node/extension_binary

※ Azure Functions Core Toolsをバージョンアップした場合には、再度リンクを貼り直す必要があります。バージョン番号(上記の例では3.0.3284)をインストールしたバージョンに合わせる必要があります。

6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2