Firebase Cloud Function deploy tslint error

末鹿安然 提交于 2020-12-09 09:53:54

问题


I started a new Firebase project with the CLI. I'm using only Cloud functions and wanted to deploy some functions but Im getting this error

functions@ lint: `tslint --project tsconfig.json`

I already changed following lines:

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

to

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

because they also threw an error.

What do I need to change?

Edit:

I created a new Firebase project (In a folder called Firebase) with the cli and only use Cloud functions. Then I copied all my .ts files into the src folder and added my dependencies.

 "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" 

Then I run firebase deploy and got the following:

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>

The log file showed:

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 ]

I just edited the directory paths where necessary.


回答1:


So I created another new project which uses hosting and functions. I got the same error as above. After searching again I found this solution. In the firebase.json file I replaced

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

with

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

After reading this issues on Github




回答2:


What it worked for me was delete node_modules from 'functions' folder and then install everything again. I think I should have tried this first instead of something else. Of course, make sure you have tslint dependency installed.



来源:https://stackoverflow.com/questions/50915952/firebase-cloud-function-deploy-tslint-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!