【问题标题】:Azure Functions: Cannot find module '@azure/cosmos'Azure Functions:找不到模块“@azure/cosmos”
【发布时间】:2021-06-09 10:37:15
【问题描述】:

我正在使用本地 git 部署 azure 功能。

我在本地运行 npm install @azure/cosmos 并安装了 @azure/cosmos。

我将代码推送到 Azure。

当我执行该函数时,错误消息显示“找不到模块'@azure/cosmos'”。

为什么?

我的功能码是:

const { CosmosClient } = require("@azure/cosmos")
module.exports = async function (context) {};

以下代码不会引发错误:

const { v4: uuid } = require('uuid')
module.exports = async function (context) {};

我的 package.json 是:

{

  "name": "name",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "start": "func start",
    "test": "echo \"No tests yet...\""
  },
  "dependencies": {
    "@azure/cosmos": "^3.11.3",
    "azure-storage": "^2.10.4",
    "uuid": "^8.3.2"
  },
  "devDependencies": {}
}

【问题讨论】:

  • 请添加一些Azure函数代码,函数是用JS写的&使用azure/cosmos包吗?
  • this tutorial能帮到你吗?
  • @TinyWang 我读过但无法修复错误。

标签: azure azure-functions azure-app-service-plans


【解决方案1】:

我在 Azure 门户中通过 SSH 运行 rm -r ./node_modules,然后重新运行 git push。然后,@azure/cosmos 就安装好了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-28
    • 1970-01-01
    相关资源
    最近更新 更多