2

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.

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?

2 Answers 2

4

I fixed this by the following workaround,

There was issue in the parserOptions.project paths. Change them to the following code:

parserOptions: {
    project: path.join(__dirname, "tsconfig.eslint.json"),
    sourceType: "module",
},

For more info, you can check out this Github Issue.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

3 Comments

Thank u for your answers. I changed them, then index.ts file has error: 'Parsing error: Cannot read file '/users/mies/firebaseprojects/{MyProject}/tsconfig.json'.'
@debug_ing that's strange. I have same .eslintrc.js as you. Can you try adding tsConfigRootDir: __dirname to parserOptions? Also what your working directory in terminal when running firebase deploy just to check?
My working directory is functions under MyProject. Regardless of the index.ts file's error. $ firebase deploy worked!. Thanks :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.