Node.js 以非零出口代码(项目路径中的空格)开头的Firebase部署错误

Node.js 以非零出口代码(项目路径中的空格)开头的Firebase部署错误,node.js,firebase,google-cloud-functions,firebase-cli,Node.js,Firebase,Google Cloud Functions,Firebase Cli,我最近在使用firebase部署命令时遇到问题。在firebase部署命令之后,除了firebase(存储、数据库等)之外,所有其他的都被部署,所以我决定重新安装firebase来解决这个问题,但在重新安装之后,我的问题变得更大了。现在,部署它们时没有出现以下错误: i deploying database, functions Running command: npm --prefix $RESOURCE_DIR run lint npm ERR! path C:\Users\faruk\Go

我最近在使用firebase部署命令时遇到问题。在firebase部署命令之后,除了firebase(存储、数据库等)之外,所有其他的都被部署,所以我决定重新安装firebase来解决这个问题,但在重新安装之后,我的问题变得更大了。现在,部署它们时没有出现以下错误:

i deploying database, functions
Running command: npm --prefix $RESOURCE_DIR run lint
npm ERR! path C:\Users\faruk\Google Drive\Android\firebase\1\$RESOURCE_DIR\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\faruk\Google Drive\Android\firebase\1\$RESOURCE_DIR\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

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

Error: functions predeploy error: Command terminated with non-zero exit code4294963238
经过一番研究,我看到了一些关于这个问题的建议

$RESOURCE_DIR to %RESOURCE_DIR%
在windows系统中(我使用的是windows 10 btw)。因此,我编辑了我的firebase.json文件,该文件位于我的functions文件夹的一个较高级别。这样地。(我不知道这是否是我应该编辑的正确文件)

但在这次编辑之后,我开始收到另一条类似这样的错误消息

i  deploying database, functions
Running command: npm --prefix %RESOURCE_DIR% run lint

Usage: npm <command>

where <command> is one of:
    access, adduser, bin, bugs, c, cache, completion, config,
    ddp, dedupe, deprecate, dist-tag, docs, doctor, edit,
    explore, get, help, help-search, i, init, install,
    install-test, it, link, list, ln, login, logout, ls,
    outdated, owner, pack, ping, prefix, profile, prune,
    publish, rb, rebuild, repo, restart, root, run, run-script,
    s, se, search, set, shrinkwrap, star, stars, start, stop, t,
    team, test, token, tst, un, uninstall, unpublish, unstar,
    up, update, v, version, view, whoami

npm <command> -h     quick help on <command>
npm -l           display full usage info
npm help <term>  search for help on <term>
npm help npm     involved overview

Specify configs in the ini-formatted file:
    C:\Users\faruk\.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@5.6.0 C:\Program Files\nodejs\node_modules\npm

Error: functions predeploy error: Command terminated with non-zero exit code1
i部署数据库、函数
正在运行的命令:npm--前缀%RESOURCE\u DIR%run lint
用法:npm
其中一个是:
访问、添加用户、bin、bug、c、缓存、完成、配置、,
ddp、重复数据消除、弃用、距离标签、文档、医生、编辑、,
探索、获取、帮助、帮助搜索、i、初始化、安装、,
安装测试、it、链接、列表、ln、登录、注销、ls、,
过时、所有者、包、ping、前缀、配置文件、修剪、,
发布、rb、重建、repo、重新启动、根目录、运行、运行脚本、,
s、 se,搜索,设置,收缩包装,星形,星形,开始,停止,t,
团队,测试,令牌,tst,取消,卸载,取消发布,取消启动,
向上,更新,v,版本,视图,whoami
npm-h的快速帮助
npm-l显示完整的使用信息
npm帮助搜索上的帮助
npm帮助npm参与概述
在ini格式的文件中指定配置:
C:\Users\faruk\.npmrc
或者在命令行上通过:npm--键值
配置信息可通过以下方式查看:npm help Config
npm@5.6.0C:\Program Files\nodejs\node\U模块\npm
错误:函数预部署错误:命令以非零退出代码1终止

任何建议都将不胜感激。提前感谢。

错误源于您的项目路径(“Google Drive”)中的某个位置有一个空间:

不幸的是,这混淆了npm命令行,它将其视为两个由该空格分隔的参数

通常情况下,我希望能够在整件事情周围加上引号,以避免空间被这样解释。所以我试了一下:

"predeploy": [
  "npm --prefix \"%RESOURCE_DIR%\" run lint"
]
这对我很有用

我将在内部与Firebase团队跟进这个问题,以及需要对Windows进行更改的事实。

对我来说,这个问题(我猜)是因为
Firebase
找不到脚本

不起作用:
{
“托管”:{
“predeploy”:“predeploy.sh”,
...
}
运行命令:predeploy.sh
events.js:160
抛出器;//未处理的“错误”事件
^
错误:spawn predeploy.sh enoint
在导出时。\u errnoException(util.js:1020:11)
在Process.ChildProcess.\u handle.onexit(内部/child\u Process.js:193:32)
在onErrorNT(内部/子进程js:367:16)
at _combinedTickCallback(内部/流程/下一步_tick.js:80:11)
在进程中。_tick回调(内部/process/next_tick.js:104:9)
位于Module.runMain(Module.js:606:11)
运行时(bootstrap_node.js:389:7)
启动时(bootstrap_node.js:149:9)
在bootstrap_node.js:504:3
错误:托管部署前错误:命令以非零退出代码1终止
确实有效:(注意
/
{
“托管”:{
“predeploy”:“/predeploy.sh”,
...
}

我在Windows中也遇到了同样的问题。我所做的是复制函数文件夹中的所有文件,并将其传递到%RESOURCE\u DIR%文件夹,然后运行Firebase部署并成功部署。

实际上,在Windows中,
Firebase.json
包含以下内容默认情况下:

"predeploy": [
  "npm --prefix \"$RESOURCE_DIR\" run lint"
]
将其修改为:

"predeploy": [
  "npm --prefix \"%RESOURCE_DIR%\" run lint"
]

它对我有用,希望对你有用。

在firebase.json中将$RESOURCE\u DIR%更改为%RESOURCE\u DIR%后,这对我有用

{
  "functions": {
    "predeploy": [
      "npm --prefix \"%RESOURCE_DIR%\" run lint",
      "npm --prefix \"%RESOURCE_DIR%\" run build"
    ]
  }
}

使用VS代码时,在firebase.json中打开Firecast的文件夹(这有助于打开资源目录的firebase.json),将文件的代码更改为:

{
“职能”:{
“部署前”:[
“npm--前缀\%RESOURCE\u DIR%\“run lint”,
“npm--前缀\%RESOURCE\u DIR%\“运行生成”
]
}
}
“部署前”:[ “npm--前缀\$RESOURCE\u DIR\“run lint” ]


最后,我在firebase.json上删除了它,它再次开始部署。在我的例子中,我创建了一个打印日志的函数,类似这样:

function log(tag: string, value: any) {
    console.log(tag, JSON.stringify(value));
}

当我在它前面添加
async
时,它开始分解构建:)

在项目run
npm install
functions文件夹中。可能您正在导入
index.ts
中一个或多个未安装的节点模块,在这种情况下,您需要运行
npm install module\u not\u installed\u-save

对我来说,上述任何一项都不起作用。最初,在一个新的firebase函数安装中,我在
非零退出代码2
上出错。因此,我删除了函数目录,重新安装,但在函数目录配置步骤中,我选择对添加lint步骤说“否”

一旦我选择不包括lint,我得到了错误
非零退出代码1

从那里检查了我的firebase.json文件并查看了predeploy脚本。因为部署过程在这一点上失败,所以我从这里开始。我的firebase.json文件如下所示:

{
    "functions": {
        "predeploy": [ "npm --prefix \"$RESOURCE_DIR\" run lint" ]
    }
}

出于某种原因,我直觉地想删除predeploy脚本中的
lint
。这修复了一切。顺便说一句,我在MacOS上。

我修复了它:你必须在另一个地方注意

你看到错误描述了吗

$ firebase deploy --only functions

=== Deploying to 'fix-firebase-functions'...

i  deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint

> functions@ lint C:\Users\vuduc\OneDrive\Tài liệu\Code tutotial         practice\test\functions
> eslint .


C:\Users\vuduc\OneDrive\Tài liệu\Code tutotial practice\test\functions\index.js
  37:16  warning  Avoid nesting promises                      promise/no-nesting
  42:13  error    Expected catch() or return                  promise/catch-or-return
  42:13  warning  Avoid nesting promises                      promise/no-nesting
  42:31  error    Each then() should return a value or throw  promise/always-return

✖ 4 problems (2 errors, 2 warnings)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions@ lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\vuduc\AppData\Roaming\npm-cache\_logs\2020-06-01T14_38_16_060Z-debug.log
events.js:287
    throw er; // Unhandled 'error' event
      ^

Error: spawn npm --prefix "%RESOURCE_DIR%" run lint ENOENT
    at notFoundError (C:\Users\vuduc\AppData\Local\Yarn\Data\global\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\Users\vuduc\AppData\Local\Yarn\Data\global\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:40:16)
    at ChildProcess.cp.emit (C:\Users\vuduc\AppData\Local\Yarn\Data\global\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:27:25)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess.cp.emit (C:\Users\vuduc\AppData\Local\Yarn\Data\global\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:30:37)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)         

  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'spawn npm --prefix "%RESOURCE_DIR%" run lint',
  path: 'npm --prefix "%RESOURCE_DIR%" run lint',
  spawnargs: []


Error: functions predeploy error: Command terminated with non-zero exit code1
您需要向上滚动以查看错误描述、行

functions predeploy error: Command terminated with non-zero exit code1
这只是一个一般性的描述,在部署之前需要修复一个错误。 这才是真正需要注意的,您需要修改哪些说明

✖ 4 problems (2 errors, 2 warnings)

谢谢你
functions predeploy error: Command terminated with non-zero exit code1
✖ 4 problems (2 errors, 2 warnings)