簡體   English   中英

通過 GitLab 在 Firebase 上部署 React 應用程序時出現“eslint:權限被拒絕”

[英]"eslint: Permission denied" when deploying React app on Firebase through GitLab

我目前正在嘗試通過 GitLab 為我托管在 Firebase 上的 React 應用程序設置 CI。 我正在努力克服這一點。 還有一些其他帖子建議使用 sudo 但控制台告訴我找不到命令。

任何幫助將不勝感激。 謝謝。

以下是我目前的配置:

gitlab-ci.yml 配置文件

 image: node:10.15.3 cache: paths: - node_modules/ stages: - build - deploy deploy_dev: stage: deploy script: - echo "Deploying to staging environment" - npm install -g firebase-tools - firebase deploy --token $FIREBASE_DEPLOY_KEY --project $CI_ENVIRONMENT_NAME environment: name: dev only: - master

包.json

 { "name": "react-app", "version": "0.1.0", "private": true, "dependencies": { "bootstrap": "^4.4.1", "firebase": "^6.6.2", "firebase-functions": "^3.3.0", "moment": "^2.24.0", "node-sass": "^4.13.1", "react": "^16.12.0", "react-beautiful-dnd": "^11.0.5", "react-dates": "^20.3.0", "react-dom": "^16.12.0", "react-moment": "^0.9.7", "react-perfect-scrollbar": "^1.5.3", "react-router-dom": "^5.1.2", "react-scripts": "^3.3.0", "reactstrap": "^8.2.0", "recompose": "^0.30.0" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }, "eslintConfig": { "extends": "react-app" }, "browserslist": [ ">0.2%", "not dead", "not ie <= 11", "not op_mini all" ] }

控制台錯誤提示權限錯誤

 $ firebase deploy -m "Pipeline $CI_PIPELINE_ID, build $CI_BUILD_ID" --non-interactive --token $FIREBASE_DEPLOY_KEY --project $CI_ENVIRONMENT_NAME ⚠ functions: package.json indicates an outdated version of firebase-functions. Please upgrade using npm install --save firebase-functions@latest in your functions directory. === Deploying to 'cmd-dev-bbdc4'... i deploying functions, hosting Running command: npm --prefix "$RESOURCE_DIR" run lint > functions@ lint /builds/cmdc/cmd/functions > eslint . sh: 1: eslint: Permission denied npm ERR! code ELIFECYCLE npm ERR! errno 126 npm ERR! functions@ lint: `eslint .` npm ERR! Exit status 126 npm ERR! npm ERR! Failed at the functions@ lint script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2020-02-03T01_51_09_788Z-debug.log Error: functions predeploy error: Command terminated with non-zero exit code126 ERROR: Job failed: exit code 1

因此,通過一些實驗,我能夠確定我必須 cd 進入“functions”目錄並運行 NPM install。 我想這是由於對 Firebase 項目的結構和節點包的基本誤解造成的。

我很想了解更多,所以如果有人分享一些關於這方面的閱讀,我們將不勝感激。

最終得到一個如下所示的腳本。

deploy_dev:
  stage: deploy
  script:
    - echo "Deploying to staging environment"
    - npm install -g firebase-tools #--allow-root
    - npm ci #--allow-root
    - cd functions # required or would throw the "eslint: not found" error
    - npm ci
    - cd ..
    - firebase use --token $FIREBASE_DEPLOY_KEY $CI_ENVIRONMENT_NAME
    - firebase deploy -m "Pipeline $CI_PIPELINE_ID, build $CI_BUILD_ID" --non-interactive --token $FIREBASE_DEPLOY_KEY
  environment:
    name: dev

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM