Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to resolve firebase deploy Parsing error: Cannot read file

I tried firebase deploy functions first time today.

When I command $ firebase deploy in the terminal, Parsing error occurred like below.

I found tsconfig.json file path is strange.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Functions directory is duplicated.

But I can’t find the way to collect the problem.

...
Running command: npm --prefix "$RESOURCE_DIR" run lint

> lint
> eslint --ext .js,.ts .

/Users/mies/FirebaseProjects/{MyProject}/functions/.eslintrc.js
  0:0  error  Parsing error: Cannot read file '/users/mies/firebaseprojects/{MyProject}/functions/functions/tsconfig.json'

/Users/mies/FirebaseProjects/{MyProject}/functions/src/index.ts
  0:0  error  Parsing error: Cannot read file '/users/mies/firebaseprojects/{MyProject}/functions/functions/tsconfig.json'

âś– 2 problems (2 errors, 0 warnings)


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

Current project structure is like below.

{MyProject}
 +- functions/
      +- node_modules/
      +- src/
          +- index.ts
      +- .eslintrc.js
      +- .gitignore
      +- package-lock.json
      +- package.json
      +- {serviceAccount}.json
      +- tsconfig.dev.json
      +- tsconfig.json
 +- .firebaserc
 +- .gitignore
 +- firebase.json
 +- firebase.indexes.json
 +- firebase.rules

.eslintrc.js

module.exports = {
  root: true,
  env: {
    es6: true,
    node: true,
  },
  extends: [
    "eslint:recommended",
    "plugin:import/errors",
    "plugin:import/warnings",
    "plugin:import/typescript",
    "google",
    "plugin:@typescript-eslint/recommended",
  ],
  parser: "@typescript-eslint/parser",
  parserOptions: {
    project: ["./functions/tsconfig.json", "./functions/tsconfig.dev.json"],
    sourceType: "module",
  },
  ignorePatterns: [
    "/lib/**/*", // Ignore built files.
  ],
  plugins: [
    "@typescript-eslint",
    "import",
  ],
  rules: {
    "quotes": ["error", "double"],
    "import/no-unresolved": 0,
  },
};

How can I fix the root /functions/functions to just /functions ?

Before this, is the correct reason for the error occred?

>Solution :

Your parserOptions.project paths are incorrect. Try changing them to:

parserOptions: {
  // No './functions/'
  project: ["tsconfig.json", "tsconfig.dev.json"],
  sourceType: "module",
},

Checkout ESLint’s documentation for more information about parserOptions.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading