gpt4 book ai didi

node.js - 使用 Kotlin 多平台时,如何将简单的 javascript 文件作为 Node 依赖项包含在 Cloud Functions for Firebase 中?

转载 作者:太空宇宙 更新时间:2023-11-03 22:50:24 25 4
gpt4 key购买 nike

我想包含一个 javascript 文件作为模块依赖项。它由 Kotlin 多平台生成,名为 common-js.js。这是我的 package.json 的一部分:

"dependencies": {
"common-js": "file:common-js"
}

我将此文件放入 node_modules/common-js.js 中,它可以与 firebaseserve 一起使用,没有任何问题。

但是,当我运行 firebase deploy 时,部署失败并显示:

Build failed: exit status 254
npm ERR! addLocal Could not install /workspace/common-js

如何使用 Cloud Functions 实现此目的?我尝试将其放入 node_modules 之外的其他目录,但它甚至在本地也不起作用。

最佳答案

Cloud Functions 目前不支持部署完全具体化的 node_modules 文件夹。在部署期间,它将执行的操作是安装 package.json 中的所有模块,并假设 npm 可以在 npm 注册表中找到它们。

如果您想将代码从您的计算机上传到 Cloud Functions,则必须将其与所有其他源代码一起包含在内。

如果您想要部署可以通过其他公共(public)源(例如 GitHub 存储库)获取的代码,则应该使用 npm 进行安装,如下所示:

npm install https://github.com/your-name/your-repo.git

如果您的代码无法公开下载,则需要将其包含在您的源代码中。

关于node.js - 使用 Kotlin 多平台时,如何将简单的 javascript 文件作为 Node 依赖项包含在 Cloud Functions for Firebase 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48632397/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com