Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error deploying with firebase on npm --prefix $RESOURCE_DIR run lint

I have a fresh install of firebase tools (following this tutorial) and I'm trying to upload my first firebase function. I get this issue with the hello-world example that they initialise when you run firebase init (The only set up the functions CLI feature during the init)

If I replace $RESOURCE_DIR in firebase.json with my functions folder it works, but of course that Is bad practice and I'd like to find a proper $RESOURCE_DIR replacement that works.

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
like image 995
Daan Luttik Avatar asked Jan 19 '18 16:01

Daan Luttik


6 Answers

Try to replace $RESOURCE_DIR with %RESOURCE_DIR% in your firebase.json file.

Multi platform solution

As seen on this post let's summarize the configuration for the different platforms you are running on:

Linux

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

PowerShell

"predeploy": [
"npm --prefix $Env:RESOURCE_DIR run lint"
]

Cmd.exe

"predeploy": [
"npm --prefix %RESOURCE_DIR% run lint"
]
like image 61
Kamil Svoboda Avatar answered Nov 15 '22 17:11

Kamil Svoboda


It wants to lint your cloud functions, meaning it will check your code for obvious errors like a compiled language would throw errors at compile time.

It's not necessary, you can always remove it by going into firebase.json and updating functions.predeploy to be an empty array.

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

What is "Linting"?

like image 35
Neo Avatar answered Nov 15 '22 15:11

Neo


you can simply make your firebase.json file like this:

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

what I'm doing is replace $RESOURCE_DIR with hard coded path of function folder itis working nice for me

like image 33
Inzamam Malik Avatar answered Nov 15 '22 16:11

Inzamam Malik


SUMMARIZING

  1. Install ESLint locally to add "devDependencies" to package.json. Run:

     `npm install eslint --save-dev`
    
  2. Workaround for Windows as stated above. Change firebase.json:

     `npm --prefix $RESOURCE_DIR run lint` to `npm --prefix %RESOURCE_DIR% run lint`
    
  3. Optionally, add the following to package.json:

     "scripts": { "lint": "eslint"} or "scripts": { "lint": "eslint.js"}
    
like image 13
Cutoutcow Avatar answered Nov 15 '22 16:11

Cutoutcow


locate the firebase.json file and then change these 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"

it'll work

like image 6
Aishik kirtaniya Avatar answered Nov 15 '22 16:11

Aishik kirtaniya


Modify in firebase.json from "npm --prefix $RESOURCE_DIR run lint" to "npm --prefix %RESOURCE_DIR% run lint"

like image 2
Bhuwan Maharjan Avatar answered Nov 15 '22 17:11

Bhuwan Maharjan