@google-cloud/functions-emulator

中文文档
1.0.0-beta.6发布于 2019/04/19Apache-2.0CommonJS近 30 天下载 1.5万

Google Cloud Functions Emulator

此软件包已被标记为弃用

Deprecating in favor of the Functions Framework and firebase-tools. See https://github.com/googlearchive/cloud-functions-emulator/issues/327

原始使用文档
文档目录6 节
  1. What is the Google Cloud Functions Emulator?
  2. Note
  3. How do I get started?
  4. Where is the documentation?
  5. Contributing
  6. License
Google Inc. logo

Google Cloud Functions Emulator

NPM Tests Coverage

Disclaimer: This is not an official Google product.

Table of Contents

What is the Google Cloud Functions Emulator?

The Google Cloud Functions Emulator is a Node.js application that implements the Google Cloud Functions API, and includes a CLI with which you can manage the application.

The Emulator allows you to deploy, run, and debug your Cloud Functions on your local machine before deploying them to the production Google Cloud Functions service.

Note

The Emulator only supports Node v6.x.x. It does not support Node v8.x.x or Python.

How do I get started?

  1. Write a function:

     mkdir helloWorld
     cd helloWorld
     touch index.js
     echo 'exports.helloWorld = (req, res) => res.send("Hello, World!");' > index.js
    
  2. Install the Emulator:

    NPM:

     npm install -g @google-cloud/functions-emulator
    

    Yarn:

     yarn global add @google-cloud/functions-emulator
    

    Or read more in the detailed installation instructions.

  3. Start the Emulator:

     functions start
    
  4. Deploy your function:

     functions deploy helloWorld --trigger-http
    

    Get help deploying a function with functions deploy --help.

  5. Call your function:

     functions call helloWorld
    
  6. View the logs:

     functions logs read
    

Where is the documentation?

For a quick reference, the Emulator CLI is self-documenting. Run the following to get help with the CLI:

functions --help

For everything else see the How-To Guides.

Contributing

To give feedback, report a bug, or request a feature, please open an issue.

To contribute a change, check out the contributing guide.

License

Copyright 2017, Google, Inc.

Licensed under the Apache License, Version 2.0

See the full license.

版本与发布记录

@google-cloud/functions-emulator 共发布 42 个版本,首次发布于 2016/10/25;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.0-beta.6latest2019/04/197 年前
1.0.0-beta.6.02019/04/177 年前
1.0.0-beta.5beta2018/08/028 年前
1.0.0-beta.42018/03/078 年前
1.0.0-beta.32018/02/248 年前
1.0.0-beta.22018/02/218 年前

其他发布通道:alpha → 1.0.0-alpha.29,beta → 1.0.0-beta.5。

关于 @google-cloud/functions-emulator 的常见问题

@google-cloud/functions-emulator 是什么?

Google Cloud Functions Emulator注意:该包已被作者标记为弃用——Deprecating in favor of the Functions Framework and firebase-tools. See https://github.com/googlearchive/cloud-functions-emulator/issues/327

如何安装 @google-cloud/functions-emulator?

在项目目录运行 npm install @google-cloud/functions-emulator,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 functions、functions-emulator,可以用 npx functions 直接运行。

@google-cloud/functions-emulator 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/google-cloud__functions-emulator 是否存在。

@google-cloud/functions-emulator 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@google-cloud/functions-emulator 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ~6。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@google-cloud/functions-emulator 可以商用吗?

@google-cloud/functions-emulator 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@google-cloud/functions-emulator 的下载量有多少?

根据 npm 官方下载统计,@google-cloud/functions-emulator 在 2026/10/17 – 2026/11/15 这 30 天内被下载 14,563 次,日均约 485 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@google-cloud/functions-emulator 还在维护吗?

最新版本 1.0.0-beta.6 发布于 2019/04/19(7 年前);至今共发布 42 个版本,其中过去 12 个月发布了 0 个;首次发布于 2016/10/25。作者已将其标记为弃用,新项目建议寻找替代方案。