"eslint: Permission denied" when deploying React app on Firebase through GitLab

I’m currently trying to setup CI through GitLab for my React app hosted on Firebase. I’m struggling to get past this point. There were some other post suggesting the use of sudo but the console told me the command was not found.

This is my first attempt at CICD so any help or resources on this particular stack would be greatly appreciated. Thanks you.

Not sure if helpful, but the job number #423373549

Here are my current configurations:

gitlab-ci.yml configuration file

image: node:10.15.3

  - node_modules/

  - build
  - deploy
  stage: deploy
    - echo "Deploying to staging environment"
    - npm install -g firebase-tools
    - firebase deploy --token $FIREBASE_DEPLOY_KEY --project $CI_ENVIRONMENT_NAME
    name: dev
    - master


  "name": "react-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "bootstrap": "^4.4.1",
    "firebase": "^6.6.2",
    "firebase-functions": "^3.3.0",
    "moment": "^2.24.0",
    "node-sass": "^4.13.1",
    "react": "^16.12.0",
    "react-beautiful-dnd": "^11.0.5",
    "react-dates": "^20.3.0",
    "react-dom": "^16.12.0",
    "react-moment": "^0.9.7",
    "react-perfect-scrollbar": "^1.5.3",
    "react-router-dom": "^5.1.2",
    "react-scripts": "^3.3.0",
    "reactstrap": "^8.2.0",
    "recompose": "^0.30.0"
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  "eslintConfig": {
    "extends": "react-app"
  "browserslist": [
    "not dead",
    "not ie <= 11",
    "not op_mini all"

The console error indicating permission error

 $ firebase deploy -m "Pipeline $CI_PIPELINE_ID, build $CI_BUILD_ID" --non-interactive --token $FIREBASE_DEPLOY_KEY --project $CI_ENVIRONMENT_NAME
 ⚠  functions: package.json indicates an outdated version of firebase-functions.
  Please upgrade using npm install --save firebase-functions@latest in your functions directory.
 === Deploying to 'cmd-dev-bbdc4'...
 i  deploying functions, hosting
 Running command: npm --prefix "$RESOURCE_DIR" run lint
 > functions@ lint /builds/cmdc/cmd/functions
 > eslint .
 sh: 1: eslint: Permission denied
 npm ERR! errno 126
 npm ERR! functions@ lint: `eslint .`
 npm ERR! Exit status 126
 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!     /root/.npm/_logs/2020-02-03T01_51_09_788Z-debug.log
 Error: functions predeploy error: Command terminated with non-zero exit code126
 ERROR: Job failed: exit code 1

So through some experimentation I was able to determine that I had to cd into the ‘functions’ directory and also run NPM install. I guess this was a due to a fundamental misunderstanding of how Firebase projects are structured and of node packages.

I would love to learn more so if anyone share some reading about this, it would be appreciated.

Ended up with a script that look like the following.

  stage: deploy
    - echo "Deploying to staging environment"
    - npm install -g firebase-tools #--allow-root
    - npm ci #--allow-root
    - cd functions # required or would throw the "eslint: not found" error
    - npm ci
    - cd ..
    - firebase use --token $FIREBASE_DEPLOY_KEY $CI_ENVIRONMENT_NAME
    - firebase deploy -m "Pipeline $CI_PIPELINE_ID, build $CI_BUILD_ID" --non-interactive --token $FIREBASE_DEPLOY_KEY
    name: dev

I had the same error.
So do I need to add this in packag.json ?