[英]How can I get “firebase deploy --only functions” command to use the package.json in the functions/ directory?
I've got the standard app structure for a Firebase/Angular application. 我已经有了Firebase / Angular应用程序的标准应用程序结构。
- functions/
|--- index.ts
|--- package.json
- src/
|--- app/
| |--- (angular stuff)
|--- index.html
|--- ...
- package.json
- firebase.json
The problem is that when I run firebase deploy --only functions
, the predeploy hooks that I've defined in firebase.json
, are called from inside the root/
directory, and not from inside root/functions/
directory. 问题是,当我运行
firebase deploy --only functions
,我在已经定义了预先部署挂钩firebase.json
,由内而外都称为root/
目录下,而不是从内部root/functions/
目录。
So for example, in root/package.json
I have 例如,在
root/package.json
中,
{
"name": "functions",
"scripts": {
"echo": "echo 'hello1'"
},
...
}
but in root/functions/package.json
I have 但是在
root/functions/package.json
中
{
"name": "functions",
"scripts": {
"echo": "echo 'hello2'"
},
...
}
and in my firebase.json
file I have 在我的
firebase.json
文件中
{
...
"functions": {
"predeploy": [
"npm run echo"
]
},
No matter whether I am in root/
or root/functions
, when I run firebase deploy --only functions
I get hello1
无论我是在
root/
还是root/functions
,当我运行firebase deploy --only functions
我会得到hello1
How do I configure my Firebase tools to use the configurations (ie namely the package.json
stuff) from functions/
when I run deploy --only functions
? 当我运行
deploy --only functions
时,如何配置Firebase工具以使用来自functions/
的配置(即package.json
内容)?
It seems the best way to get this working, according to the Firebase Typescript docs , is to specify the predeploy
hook as follows 根据Firebase Typescript文档 ,似乎最好的方法是按照以下方式指定
predeploy
挂钩:
{
"functions": {
"predeploy": "npm --prefix functions run build",
}
}
This calls npm run build
from inside the functions
directory, so it will call the build
script in functions/package.json
and not the project root's package.json
这从
functions
目录内部调用npm run build
,因此它将在functions/package.json
而不是项目根目录的package.json
调用build
脚本package.json
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.