在npm上使用firebase部署时出错--prefix $ RESOURCE_DIR运行lint

问题描述 投票:49回答:8

我有一个全新安装的firebase工具(遵循此tutorial),我正在尝试上传我的第一个firebase功能。我在hello-world示例中遇到了这个问题,它们在运行firebase init时初始化(在init期间唯一设置函数CLI功能)

如果我将$RESOURCE_DIR中的firebase.json替换为我的函数文件夹,它可以工作,但当然这是不好的做法,我想找到一个合适的$RESOURCE_DIR替代品。

PS D:\workspace\firebase-functions> firebase deploy

    === Deploying to 'newagent-5221d'...

i  deploying functions
Running command: npm --prefix $RESOURCE_DIR run lint
npm ERR! path D:\workspace\firebase-functions\$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 'D:\workspace\firebase-functions\$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\dtlut\AppData\Roaming\npm-cache\_logs\2018-01-19T15_57_22_990Z-debug.log

Error: functions predeploy error: Command terminated with non-zero exit code4294963238
firebase npm google-cloud-functions
8个回答
113
投票

尝试在firebase.json文件中用%RESOURCE_DIR%替换$ RESOURCE_DIR。


26
投票

你可以像这样简单地制作你的firebase.json文件:

{
  "functions": {
    "predeploy": [
      "npm --prefix ./functions/ run lint",
      "npm --prefix ./functions/ run build"
    ]
  }
}

我正在做的是用函数文件夹的硬编码路径替换$ RESOURCE_DIR它对我来说很好用


19
投票

它想要提示你的云功能,这意味着它会检查你的代码是否有明显的错误,比如编译语言会在编译时抛出错误。

没有必要,你总是可以通过进入firebase.json并将functions.predeploy更新为空数组来删除它。

  "functions": {
    "predeploy": [],
    "source": "functions" 
  }

What is "Linting"?


8
投票

总结

  1. 在本地安装ESLint以将“devDependencies”添加到package.json。跑: `npm install eslint --save-dev`
  2. 如上所述的Windows解决方法。改变firebase.json: `npm --prefix $RESOURCE_DIR run lint` to `npm --prefix %RESOURCE_DIR% run lint`
  3. (可选)将以下内容添加到package.json: "scripts": { "lint": "eslint"} or "scripts": { "lint": "eslint.js"}

4
投票

找到firebase.json文件,然后更改这些行

"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"

"npm --prefix \"%RESOURCE_DIR%\" run lint",
"npm --prefix \"%RESOURCE_DIR%\" run build"

它会工作的


1
投票

在firebase.json中将“npm --prefix $RESOURCE_DIR run lint”修改为“npm --prefix %RESOURCE_DIR% run lint


0
投票

这个应该解决这个问题没有解决方法

npm install -g git://github.com/firebase/firebase-tools#master

请在项目文件夹中再次尝试此安装,它应该解决问题。


-1
投票

它正在成功地实现我的云功能部署

"functions": {
"predeploy": [
  "npm --prefix \"%RESOURCE_DIR%\" run lint",
  "npm --prefix \"%RESOURCE_DIR%\" run build"
],`enter code here`
"source": "functions"
© www.soinside.com 2019 - 2024. All rights reserved.