javascript - Azure 和 MicrosoftGraph Api 部署抛出 "Error: Method Not Allowed"

标签 javascript node.js azure azure-web-app-service microsoft-graph-api

我想在azure中部署一个应用程序Web服务,但我遇到的问题是,如果我添加到microsoft graph api的依赖项,当我更新git并继续部署时,服务器返回“错误:不允许的方法”。

这是应用程序 github(它是我用来测试的一个简单的 helloWorld 应用程序): https://github.com/ricardoGuerreroAvantica/test_azure_helloworld

这是我在部署时收到的错误日志:

Command: "D:\home\site\deployments\tools\deploy.cmd".

Handling node.js deployment.
Creating app_offline.htm
KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot'
Copying file: 'package-lock.json'
Copying file: 'package.json'
Deleting app_offline.htm
Looking for app.js/server.js under site root.
Using start-up script app.js
Generated web.config.
The package.json file does not specify node.js engine version constraints.
The node.js application will run with the default node.js version 0.10.40.
Selected npm version 1.4.28
npm WARN package.json <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bfccdacbd6d2d2dadbd6decbdaff8e918f918a" rel="noreferrer noopener nofollow">[email protected]</a> No README data
npm WARN package.json <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="660405141f16124b16040d0200265748564857" rel="noreferrer noopener nofollow">[email protected]</a> No repository field.
npm WARN package.json <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f282879c8b919d9697b2c0dcc3dcc2" rel="noreferrer noopener nofollow">[email protected]</a> punycode is also the name of a node core module.
npm WARN package.json <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="88f8e9fce0c8b8a6b9baa6bf" rel="noreferrer noopener nofollow">[email protected]</a> path is also the name of a node core module.
npm WARN package.json <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e09081959385a0d0ced0ced1" rel="noreferrer noopener nofollow">[email protected]</a> No repository field.
npm WARN package.json <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1e6b6a77725e2e302f2e302d" rel="noreferrer noopener nofollow">[email protected]</a> util is also the name of a node core module.
npm WARN package.json <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2f5c5b5d464148704b4a4c404b4a5d6f1e011f011c" rel="noreferrer noopener nofollow">[email protected]</a> string_decoder is also the name of a node core module.
npm ERR! Error: Method Not Allowed
npm ERR!     at errorResponse (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\lib\cache\add-named.js:260:10)
npm ERR!     at D:\Program Files (x86)\npm\1.4.28\node_modules\npm\lib\cache\add-named.js:203:12
npm ERR!     at saved (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\npm-registry-client\lib\get.js:167:7)
Failed exitCode=1, command="D:\Program Files (x86)\nodejs\0.10.40\node.exe" "D:\Program Files (x86)\npm\1.4.28\node_modules\npm\bin\npm-cli.js" install --production
npm ERR!     at Object.oncomplete (fs.js:108:15)
An error has occurred during web site deployment.
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "D:\\Program Files (x86)\\nodejs\\0.10.40\\node.exe" "D:\\Program Files (x86)\\npm\\1.4.28\\node_modules\\npm\\bin\\npm-cli.js" "install" "--production"
npm ERR! cwd D:\home\site\wwwroot
npm ERR! node -v v0.10.40
npm ERR! npm -v 1.4.28
npm ERR! code E405
npm WARN package.json <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="334056475a5e5e56575a52475673021d031d06" rel="noreferrer noopener nofollow">[email protected]</a> No README data\r\nnpm WARN package.json <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8defeefff4fdf9a0fdefe6e9ebcdbca3bda3bc" rel="noreferrer noopener nofollow">[email protected]</a> No repository field.\r\nnpm WARN package.json <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ccbcb9a2b5afa3a8a98cfee2fde2fc" rel="noreferrer noopener nofollow">[email protected]</a> punycode is also the name of a node core module.\r\nnpm WARN package.json <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6b1b0a1f032b5b455a59455c" rel="noreferrer noopener nofollow">[email protected]</a> path is also the name of a node core module.\r\nnpm WARN package.json <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d5a5b4a0a6b095e5fbe5fbe4" rel="noreferrer noopener nofollow">[email protected]</a> No repository field.\r\nnpm WARN package.json <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f481809d98b4c4dac5c4dac7" rel="noreferrer noopener nofollow">[email protected]</a> util is also the name of a node core module.\r\nnpm WARN package.json <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="572423253e39300833323438333225176679677964" rel="noreferrer noopener nofollow">[email protected]</a> string_decoder is also the name of a node core module.\r\nnpm ERR! Error: Method Not Allowed\r\nnpm ERR!     at errorResponse (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\lib\cache\add-named.js:260:10)\r\nnpm ERR!     at D:\Program Files (x86)\npm\1.4.28\node_modules\npm\lib\cache\add-named.js:203:12\r\nnpm ERR!     at saved (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\npm-registry-client\lib\get.js:167:7)\r\nnpm ERR!     at Object.oncomplete (fs.js:108:15)\r\nnpm ERR! If you need help, you may report this *entire* log,\r\nnpm ERR! including the npm and node versions, at:\r\nnpm ERR!     <http://github.com/npm/npm/issues>\r\n\r\nnpm ERR! System Windows_NT 6.2.9200\r\nnpm ERR! command "D:\\Program Files (x86)\\nodejs\\0.10.40\\node.exe" "D:\\Program Files (x86)\\npm\\1.4.28\\node_modules\\npm\\bin\\npm-cli.js" "install" "--production"\r\nnpm ERR! cwd D:\home\site\wwwroot\r\nnpm ERR! node -v v0.10.40\r\nnpm ERR! npm -v 1.4.28\r\nnpm ERR! code E405\r\nD:\Program Files (x86)\SiteExtensions\Kudu\79.11121.3655\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"

最佳答案

根据您的错误信息,您是在 Azure WebApps 的默认 Node.js 版本 0.10.40 上部署应用程序,这导致了您的问题,因为 msgraph-sdk-javascript 您的应用程序依赖的包需要 NodeJS 更高版本。

正如 GitHub Repo README.md 所说,它已经使用 v6.9.1 进行了测试,因此您可以通过添加记录来升级 Azure WebApp 的 Node 版本Azure 门户上的应用程序设置中的WEBSITE_NODE_DEFAULT_VERSION6.9.1如下图所示,来 self 对类似SO线程的回答Kudu npm install failed您也可以引用一下。

enter image description here

关于javascript - Azure 和 MicrosoftGraph Api 部署抛出 "Error: Method Not Allowed",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53729394/

相关文章:

javascript - 无法从 React-Native-Firebase(v6) Firestore : undefined is not a function (near '...this._firestore.native.collectionGet...' ) 获取数据

javascript - 隐藏内容时使div跳动更平滑

javascript - slider 图像需要一些时间来加载。

javascript - 以编程方式在 Openlayers 中使用 anchor 进行缩放

node.js - 在 angular2 quickstart 中安装 npm 的 Node 模块过多

javascript - JavaScript 和 Node.js 中多个请求之间的局部变量

javascript - Razor页面javascript仅执行c#一次

node.js - 可怕的错误 : bad content-type header, 未知内容类型:文本/纯文本;字符集=UTF-8

java - 如何从 Azure key 保管库获取 Azure 存储帐户访问 key

Azure Devops API 创建构建定义