【问题标题】:Travis deploy Firebase hosting files not found未找到 Travis 部署 Firebase 托管文件
【发布时间】:2019-06-13 12:19:48
【问题描述】:

我正在尝试通过 Travis CI 在 Firebase 托管上进行部署,但在我的构建生成要部署的静态文件后,deploy 阶段似乎在输出文件中找不到文件 www。 Travis 会删除 script 和 deploy 之间的文件吗?

.travis.yml

---
language: node_js
node_js:
  - lts/*
install:
  - npm install @vue/cli
  - npm install
script:
  - npm test
  - npm run build
deploy:
  provider: firebase
  project: my-firebase-project
  token:
    secure: FIREBASE_SECURE_TOKEN
cache:
  directories:
    - node_modules

firebase.json

{
  "hosting": {
    "public": "www",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}

这是我的 Travis 构建日志:

...

 DONE  Build complete. The www directory is ready to be deployed.
 INFO  Check out deployment instructions at https://cli.vuejs.org/guide/deployment.html

...

=== Deploying to 'my-firebase-project'...
i  deploying database, hosting
i  database: checking rules syntax...
✔  database: rules syntax for database my-firebase-project is valid
i  hosting[my-firebase-project]: beginning deploy...
i  hosting[my-firebase-project]: found 0 files in www
✔  hosting[my-firebase-project]: file upload complete
i  database: releasing rules...
(node:6919) UnhandledPromiseRejectionWarning: Error
    at new FirebaseError (/home/travis/.nvm/versions/node/v10.15.0/lib/node_modules/firebase-tools/lib/error.js:11:16)
    at Object.reject (/home/travis/.nvm/versions/node/v10.15.0/lib/node_modules/firebase-tools/lib/utils.js:135:27)
    at /home/travis/.nvm/versions/node/v10.15.0/lib/node_modules/firebase-tools/lib/deploy/hosting/prepare.js:60:20
    at arrayEach (/home/travis/.nvm/versions/node/v10.15.0/lib/node_modules/firebase-tools/node_modules/lodash/lodash.js:516:11)
    at Function.forEach (/home/travis/.nvm/versions/node/v10.15.0/lib/node_modules/firebase-tools/node_modules/lodash/lodash.js:9344:14)
    at module.exports (/home/travis/.nvm/versions/node/v10.15.0/lib/node_modules/firebase-tools/lib/deploy/hosting/prepare.js:39:5)
    at _chain (/home/travis/.nvm/versions/node/v10.15.0/lib/node_modules/firebase-tools/lib/deploy/index.js:26:38)
    at /home/travis/.nvm/versions/node/v10.15.0/lib/node_modules/firebase-tools/lib/deploy/index.js:29:14
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:6919) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6919) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✔  database: rules for database my-firebase-project released successfully
i  hosting[my-firebase-project]: finalizing version...
Error: HTTP Error: 404, Not Found

【问题讨论】:

    标签: firebase travis-ci firebase-hosting firebase-cli


    【解决方案1】:

    当./www/index.html不存在时,会产生404

    正如this 提示的那样,位置必须是:"public": "./www"。

    【讨论】:

    • 这似乎是我本地计算机上的 NodeJS 和 Travis 的相同版本:节点版本:v10.15.0 和 npm 版本:6.4.1。但是,我可以从我的计算机进行部署
    • @vietnem 这些警告可以忽略;路径很可能有问题。
    猜你喜欢
    • 1970-01-01
    • 2019-04-02
    • 2018-12-17
    • 2018-12-30
    • 2017-08-14
    • 2021-03-03
    • 1970-01-01
    • 2015-04-18
    • 2020-01-14
    相关资源
    最近更新 更多