node.js - 我如何观察我的天蓝色功能的变化?
问题描述
我正在使用用 NODE JS 编写的天蓝色函数。我正在启动本地服务器
func host start
一切正常。但问题是当我在我的天蓝色函数中更改某些内容时 - 例如当我添加一个简单的控制台日志时的 index.js 文件
module.exports = async function (context, req) {
console.log('request came');
context.res = {
body: { success: true, message: null, response: context.bindings.inputDocument }
};
};
服务器未重新启动,我需要停止服务器再次运行 func host start 以查看不好的更改。在nodejs中,我们有nodemon,在天蓝色的函数中是否有一些东西,我可以在不停止并在每次更改时启动服务器的情况下观察更改?
我试过的
我尝试在我的 host.json 文件中添加
"watchDirectories": [ "*" ]
但没有成功。
我也试过
scripts
编辑package.json 文件中的 start 属性
"scripts": {
"start": "start npm run watch & npm run start:host",
"test": "echo \"No tests yet...\""
},
反而
"scripts": {
"start": "func start",
"test": "echo \"No tests yet...\""
},
但仍然没有成功。
我正在使用天蓝色函数 v2。
解决方案
您可以启动两个进程(基于@azure/functions 1.2.3):
- 过程1:(
tsc -w
或npm run watch
) - 过程2:(
func start
或npm start
)
然后,Typescript 编译器将在监视模式下工作,自动编译更改,并且 azure func 工具还将在更改时重新加载它的函数。
推荐阅读
- corda - net.corda.core.contracts.TransactionVerificationException$ContractRejection:合同验证失败:
- c# - 如何打包 Visual Studio aws 无服务器项目?
- reactjs - 使用 try/catch 处理 413(请求实体太大)错误
- c# - 找不到 net471 System.Configuration.Install 命名空间
- javascript - Promise.all 没有进入
- html - 如何更改行引导程序 3 中元素的顺序?
- c# - 如何从 URL 导入文本?
- git - 使用 fork 同步 github 上游
- python - TimeInput 的初始格式
- ftp - 使用 FileMaker 或 Applescript FTP 下载最新文件