'npm err missing script lint when deploying

When running the following command:

npm --prefix "$RESOURCE_DIR" run lint

It returns the following error:

npm ERR! missing script: lint

npm ERR! A complete log of this run can be found in:

npm ERR! C:\Users\HP\AppData\Roaming\npm-cache\_logs\2018-04-13T01_27_59_009Z-debug.log

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

This is my package.json:

  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "serve": "firebase serve --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "dependencies": {
    "firebase-admin": "~5.12.0",
    "firebase-functions": "^1.0.1"
  },
  "private": true
}


Solution 1:[1]

You are trying to run the lint task, but it doesn't exist in your package definition. Are you sure you're not wanting to run the following (based on your question title)?

npm --prefix "$RESOURCE_DIR" run deploy

Edit: ok, looks like Firebase expects a lint script. So just add "lint": "" to your scripts.

Solution 2:[2]

I was getting same error while deploying firebase cloud functions written in typescript. Under package.json, I added following lines. Then the function got deployed successfully.

under scripts ->

"lint": "tslint --project tsconfig.json",

Under devDependencies ->

"tslint": "^5.12.0",

Solution 3:[3]

the linter package isn't installed , if you need to deploy without run linter you can remove the those lines from firbase.json file

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

Solution 4:[4]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2
Solution 3 Mohammad Desouky
Solution 4 Vijay