# #firebase #vue.js
Вопрос:
Я получаю error Parsing error: Unexpected token =gt;
это, когда пытаюсь развернуть свое приложение Vue JS в firebase. Приложение отлично работает на моей локальной машине, но я не могу развернуть его в firebase.
Вот полная ошибка
=== Deploying to 'mmmmnl-d5ddc'... i deploying storage, firestore, functions, hosting Running command: npm --prefix "$RESOURCE_DIR" run lint gt; lint gt; eslint . /Users/KingdomMac/Downloads/ermnl_delivery/ermnl-dashboard/functions/index.js 22:71 error Parsing error: Unexpected token =gt; ✖ 1 problem (1 error, 0 warnings) Error: functions predeploy error: Command terminated with non-zero exit code1
Я добавил ecmaVersion: 8
к parserOptions
этому . Я изменил его на 6, я также изменил его на 2017 год, как указано в некоторых других ответах.
Вот мое .eslintrc.js
досье
module.exports = { root: true, env: { node: true }, extends: ["plugin:vue/essential", "@vue/prettier"], rules: { 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off' }, parserOptions: { parser: 'babel-eslint', ecmaVersion: 2017 }, 'extends': [ 'plugin:vue/essential', '@vue/prettier', '@vue/standard' ] };
Вот мой файл package.json
{ "name": "vue-white-dashboard", "version": "0.1.0", "private": true, "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", "lint": "vue-cli-service lint" }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^1.2.35", "@fortawesome/free-brands-svg-icons": "^5.15.3", "@fortawesome/free-regular-svg-icons": "^5.15.3", "@fortawesome/free-solid-svg-icons": "^5.15.3", "@fortawesome/vue-fontawesome": "^2.0.2", "axios": "^0.21.1", "chart.js": "^2.8.0", "core-js": "^2.6.5", "firebase": "^8.6.8", "node-sass": "^6.0.1", "vue": "^2.6.10", "vue-chartjs": "^3.4.2", "vue-click-outside": "^1.0.7", "vue-clickaway": "^2.2.2", "vue-github-buttons": "^3.1.0", "vue-i18n": "^8.14.1", "vue-router": "^3.0.3", "vue-social-sharing": "^2.4.6", "vue2-transitions": "^0.3.0", "vuetify": "^2.4.0" }, "devDependencies": { "@vue/cli-plugin-babel": "^3.3.0", "@vue/cli-plugin-eslint": "^3.1.1", "@vue/cli-service": "^4.5.15", "@vue/eslint-config-prettier": "^5.0.0", "@vue/eslint-config-standard": "^5.1.2", "babel-eslint": "^10.1.0", "eslint": "^8.2.0", "eslint-config-eslint": "^7.0.0", "eslint-config-google": "^0.14.0", "eslint-config-prettier": "^8.3.0", "eslint-config-standard": "^16.0.3", "eslint-plugin-import": "^2.20.2", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^3.1.0", "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.0", "eslint-plugin-vue": "^7.14.0", "prettier": "^1.18.2", "sass": "~1.32", "sass-loader": "^10.0.0", "vue-cli-plugin-vuetify": "~2.4.1", "vue-template-compiler": "^2.6.10", "vuetify-loader": "^1.7.0" } }
None of the the other resources I have read points out the problem to be from their code. But I am just adding functions/index.js
here incase the problem is from the that file.
const functions = require("firebase-functions"); const admin = require("firebase-admin"); admin.initializeApp(); const db = admin.firestore(); exports.addUserRole = functions.auth.user().onCreate(async (authUser) =gt; { if (authUser.email) { const customClaims = { admin: true, }; try { let _ = await admin.auth().setCustomUserClaims(authUser.uid, customClaims); return db.collection("roles").doc(authUser.uid).set({ email: authUser.email, role: customClaims, }); } catch (error) { console.log(error); } } }); exports.setUserRole = functions.https.onCall(async (data, context) =gt; { if (!context.auth.token.admin) return try { let _ = await admin.auth().setCustomUserClaims(data.uid, data.role) return db.collection("roles").doc(data.uid).update({ role: data.role }) } catch (error) { console.log(error) } });
Как и было запрошено в комментариях, я добавил свой firebase.json
{ "firestore": { "rules": "firestore.rules", "indexes": "firestore.indexes.json" }, "functions": { "predeploy": [ "npm --prefix "$RESOURCE_DIR" run lint" ], "source": "functions" }, "storage": { "rules": "storage.rules" }, "hosting": { "public": "dist", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "rewrites": [ { "source": "**", "destination": "/index.html" } ] } }
Комментарии:
1. Можете ли вы также поделиться своим файлом firebase.json, пожалуйста?
2. @Абдуллаххан, я добавил это