Reputation: 702
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?
Upvotes: 2
Views: 589
Reputation: 584
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.
Upvotes: 4
Reputation: 50860
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
.
Upvotes: 1