如何解决从Gitlab到Firebase的React部署失败,并出现以下错误:到指定的公共目录“ build”不存在,无法将主机部署到站点
这是firebase.json文件
{ "hosting": { "public": "build","ignore": [ "firebase.json","**/.*","**/node_modules/**" ],"rewrites": [ { "source": "**","destination": "/index.html" } ] } }
@H_404_5@这是我的
.gitlab-ci.yml
:image: tragopoulos/firebase:latest stages: - build - test - deploy cache: paths: - node_modules/ key: "$CI_BUILD_REPO" build: stage: build image: node script: - echo "# Start building App" - npm install - npm build - echo "# Build successfully!" artifacts: expire_in: 1 hour paths: - "/build" - node_modules/ test: stage: test image: node script: - echo "# Testing App" - npm install - CI=true npm test - echo "# Test successfully!" deploy-develop: stage: deploy environment: tragopoulos-portfolio-dev only: - develop before_script: - npm install - npm build script: - echo "# deploying App" - firebase use tragopoulos-portfolio --token $FIREBASE_TOKEN - firebase deploy --only hosting -m "Pipeline $CI_PIPELINE_ID Build $CI_BUILD_ID" - echo "# Deployed successfully!"
@H_404_5@这是错误:
我尝试了“ build”,“ / build”,“ / build /”,“ / PROJECT_NAME / build”,但没有任何效果。我也不知道如何
$ echo
构建路径,因此我可以在项目中对其进行调试。在Angular中,“ dist”可以正常工作。有想法吗?解决方法
根据评论部分的讨论,似乎在部署步骤中没有创建
build
文件夹。它们很可能在不同的容器中运行。因此,firebase deploy
命令找不到必要的build
。我会尝试从
before_script
中删除.gitlab-ci.yml
,并将其步骤与script
合并为:script: - npm install - npm build - echo "# Deploying App" - firebase use tragopoulos-portfolio --token $FIREBASE_TOKEN - firebase deploy --only hosting -m "Pipeline $CI_PIPELINE_ID Build $CI_BUILD_ID" - echo "# Deployed successfully!"
这样,您就可以在部署步骤中放置
build
文件夹了。版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。