5

我使用 CLI 启动了一个新的 Firebase 项目。我只使用云功能并想部署一些功能,但我收到此错误

functions@ lint: `tslint --project tsconfig.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"

因为他们也抛出了一个错误。

我需要改变什么?

编辑:

我用 cli 创建了一个新的 Firebase 项目(在一个名为 Firebase 的文件夹中),并且只使用 Cloud 函数。然后我将所有 .ts 文件复制到 src 文件夹中并添加了我的依赖项。

 "firebase-admin": "~5.12.1",
 "firebase-functions": "^1.0.3",
 "@types/async": "^2.0.48",
 "@types/camelcase": "^4.1.0",
 "@types/glob": "^5.0.35",
 "@types/request": "^2.47.0",
 "@types/xml2js": "^0.4.2",
 "async": "^2.6.0",
 "camelcase": "^4.1.0",
 "glob": "^7.1.2",
 "install": "0.10.4",
 "npm": "5.6.0",
 "request": "^2.85.0",
 "xml2js": "^0.4.19" 

然后我运行 firebase deploy 并得到以下信息:

i  deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
npm ERR! path C:\...\Projects\Firebase\%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:\...\Projects\Firebase\%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:\...\AppData\Roaming\npm-cache\_logs\2018-06-19T20_48_36_986Z-debug.log

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

C:\...\Projects\Firebase>

日志文件显示:

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   '%RESOURCE_DIR%',
1 verbose cli   'run',
1 verbose cli   'lint' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose stack Error: ENOENT: no such file or directory, open 'C:\...\Projects\Firebase\%RESOURCE_DIR%\package.json'
5 verbose cwd C:\...\Projects\Firebase
6 verbose Windows_NT 10.0.17134
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "--prefix" "%RESOURCE_DIR%" "run" "lint"
8 verbose node v8.9.4
9 verbose npm  v5.6.0
10 error path C:\...\Projects\Firebase\%RESOURCE_DIR%\package.json
11 error code ENOENT
12 error errno -4058
13 error syscall open
14 error enoent ENOENT: no such file or directory, open 'C:\...\Projects\Firebase\%RESOURCE_DIR%\package.json'
15 error enoent This is related to npm not being able to find a file.
16 verbose exit [ -4058, true ]

我只是在必要时编辑了目录路径。

4

3 回答 3

6

所以我创建了另一个使用托管和功能的新项目。我得到了和上面一样的错误。再次搜索后,我找到了这个解决方案。在我替换的 firebase.json 文件中

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

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

在 Github 上阅读此问题后

于 2018-06-22T15:55:05.647 回答
4

它对我有用的是从'functions'文件夹中删除node_modules,然后再次安装所有东西。我想我应该先尝试这个而不是别的。当然,请确保您安装了 tslint 依赖项。

于 2018-10-21T03:12:08.580 回答
0

在您的项目中重新初始化 firebase

firebase init
于 2021-03-26T03:40:34.863 回答