gui*_*efd 7 firebase typescript firebase-tools google-cloud-functions
我正在尝试使用打字稿的云功能.
成功安装后,添加了触发器并进行了测试部署.
index.ts
import * as functions from 'firebase-functions';
export const createAccount = functions.auth.user().onCreate(event => {
const user = event.data;
console.log('user displayname', user.displayName);
return;
});
Run Code Online (Sandbox Code Playgroud)
命令
firebase deploy --only functions
=== Deploying to 'project'...
i deploying functions
i functions: running predeploy script.
> functions@ build D:\vmbox\project\firebase\functions
> tslint -p tslint.json && ./node_modules/.bin/tsc
Run Code Online (Sandbox Code Playgroud)
错误
'.' is not recognized as an internal or external command,
operable program or batch file.
Run Code Online (Sandbox Code Playgroud)
环境
firebase cli v3.16.0
node v6.11.2
npm v4.2.0
操作系统:Windows 10
终端:powershell
///
我使用Javascript选项重新启动了函数,并在部署时遇到错误.
我想这可能与cli为打字稿做的设置有关.
不得不删除添加到"firebase.json"的"函数"选项.
firebase.json中删除了选项:
"functions": {
"predeploy": "npm --prefix functions run build"
}
Run Code Online (Sandbox Code Playgroud)
And*_*sov 15
刚内更换package.json此
"build": "./node_modules/.bin/tslint.cmd -p tslint.json && ./node_modules/.bin/tsc.cmd"
Run Code Online (Sandbox Code Playgroud)
就此而言
"build": ".\\node_modules\\.bin\\tslint.cmd -p tslint.json && .\\node_modules\\.bin\\tsc.cmd"
Run Code Online (Sandbox Code Playgroud)
它将适用于Windows.
将此行添加到functions文件夹内的tsconfig中:
"typeRoots": [
"node_modules/@types"
],
Run Code Online (Sandbox Code Playgroud)
这是为我工作的“ compilerOptions”块的一部分
抱歉耽搁了.安德鲁的答案可行,但它使该项目现在只适用于Windows.有关更多信息,您可以在此处查看我的GitHub答案.TL; DR:
将package.json中的脚本更改为:
"scripts": {
"lint": "./node_modules/.bin/tslint -p tslint.json",
"build": "./node_modules/.bin/tsc"
}
Run Code Online (Sandbox Code Playgroud)
将firebase.json中的predeploy挂钩更改为:
{
"functions": {
"predeploy": "npm --prefix functions run lint && npm --prefix functions run build"
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4525 次 |
| 最近记录: |