1

这是第一次发生在我身上。我曾多次尝试初始化 firebase,但仍然得到相同的结果。

当我尝试使用命令部署功能时:

firebase deploy --only functions

控制台接下来返回:

=== Deploying to 'hay-equipo-3a19b'...

i  deploying functions
Running command: npm --prefix functions run build
npm ERR! missing script: build

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Usuario\AppData\Roaming\npm-cache\_logs\2018-01-24T21_36_36_260Z-debug.log

Error: functions predeploy error: Command terminated with non-zero exit code1

这是我的函数文件夹的 package.json

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "serve": "firebase serve --only functions",
    "shell": "firebase experimental:functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "dependencies": {
    "firebase-admin": "~5.8.1",
    "firebase-functions": "^0.8.1",
    "nodemailer": "^4.4.2"
  },
  "private": true
}

日志文件说

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   '--prefix',
1 verbose cli   'functions',
1 verbose cli   'run',
1 verbose cli   'build' ]
2 info using npm@5.5.1
3 info using node@v8.9.3
4 verbose stack Error: missing script: build
4 verbose stack     at run (C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:151:19)
4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:61:5
4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:115:5
4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:402:5
4 verbose stack     at checkBinReferences_ (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:357:45)
4 verbose stack     at final (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:400:3)
4 verbose stack     at then (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:160:5)
4 verbose stack     at ReadFileContext.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:332:20)
4 verbose stack     at ReadFileContext.callback (C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16)
4 verbose stack     at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:420:13)
5 verbose cwd C:\Users\Usuario\Projects\torneos-club-oeste
6 verbose Windows_NT 10.0.16299
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "--prefix" "functions" "run" "build"
8 verbose node v8.9.3
9 verbose npm  v5.5.1
10 error missing script: build
11 verbose exit [ 1, true ]
4

1 回答 1

0

似乎如果您只是在“脚本”下的文件中输入一个空白"build"条目functions/package.json,那么它可以解决这个问题(它对我来说很好)。

{
    "scripts": {
        "build": "",   <----- simply add this!
        ...
    },
    ...
}
于 2020-11-02T05:08:42.207 回答