使用Travis部署时渲染角度页面失败

时间:2019-04-30 09:41:20

标签: angular travis-ci

我正在使用travis部署有角度的Web应用程序,并遇到以下错误。构建运行良好,在渲染内容时遇到问题。即ng build --prod命令运行正常。但是,每当我尝试从浏览器访问该应用程序时,都会在控制台中得到一个带有以下错误消息的空白页面。但是,如果我从自己的机器上构建和部署相同的角度应用程序,则该应用程序将按预期工作。

main.ab3e11a36e446f1405c1.js:1 ERROR Error: Uncaught (in promise): TypeError: Cannot read property '__source' of undefined
TypeError: Cannot read property '__source' of undefined
    at t.get (main.ab3e11a36e446f1405c1.js:1)
    at cg (main.ab3e11a36e446f1405c1.js:1)
    at t.get (main.ab3e11a36e446f1405c1.js:1)
    at je (main.ab3e11a36e446f1405c1.js:1)
    at Te (main.ab3e11a36e446f1405c1.js:1)
    at Ie (main.ab3e11a36e446f1405c1.js:1)
    at main.ab3e11a36e446f1405c1.js:1
    at main.ab3e11a36e446f1405c1.js:1
    at hg (main.ab3e11a36e446f1405c1.js:1)
    at cg (main.ab3e11a36e446f1405c1.js:1)
    at P (polyfills.8a08c7bebefd1a5e8a0e.js:1)
    at P (polyfills.8a08c7bebefd1a5e8a0e.js:1)
    at polyfills.8a08c7bebefd1a5e8a0e.js:1
    at e.invokeTask (polyfills.8a08c7bebefd1a5e8a0e.js:1)
    at Object.onInvokeTask (main.ab3e11a36e446f1405c1.js:1)
    at e.invokeTask (polyfills.8a08c7bebefd1a5e8a0e.js:1)
    at t.runTask (polyfills.8a08c7bebefd1a5e8a0e.js:1)
    at g (polyfills.8a08c7bebefd1a5e8a0e.js:1)
Cp @ main.ab3e11a36e446f1405c1.js:1
t.handleError @ main.ab3e11a36e446f1405c1.js:1
next @ main.ab3e11a36e446f1405c1.js:1
o @ main.ab3e11a36e446f1405c1.js:1
e.__tryOrUnsub @ main.ab3e11a36e446f1405c1.js:1
e.next @ main.ab3e11a36e446f1405c1.js:1
e._next @ main.ab3e11a36e446f1405c1.js:1
e.next @ main.ab3e11a36e446f1405c1.js:1
e.next @ main.ab3e11a36e446f1405c1.js:1
e.emit @ main.ab3e11a36e446f1405c1.js:1
(anonymous) @ main.ab3e11a36e446f1405c1.js:1
e.invoke @ polyfills.8a08c7bebefd1a5e8a0e.js:1
t.run @ polyfills.8a08c7bebefd1a5e8a0e.js:1
t.runOutsideAngular @ main.ab3e11a36e446f1405c1.js:1
onHandleError @ main.ab3e11a36e446f1405c1.js:1
e.handleError @ polyfills.8a08c7bebefd1a5e8a0e.js:1
t.runGuarded @ polyfills.8a08c7bebefd1a5e8a0e.js:1
e @ polyfills.8a08c7bebefd1a5e8a0e.js:1
r.microtaskDrainDone @ polyfills.8a08c7bebefd1a5e8a0e.js:1
g @ polyfills.8a08c7bebefd1a5e8a0e.js:1
Promise.then (async)
v @ polyfills.8a08c7bebefd1a5e8a0e.js:1
e.scheduleTask @ polyfills.8a08c7bebefd1a5e8a0e.js:1
onScheduleTask @ polyfills.8a08c7bebefd1a5e8a0e.js:1
e.scheduleTask @ polyfills.8a08c7bebefd1a5e8a0e.js:1
t.scheduleTask @ polyfills.8a08c7bebefd1a5e8a0e.js:1
t.scheduleMicroTask @ polyfills.8a08c7bebefd1a5e8a0e.js:1
I @ polyfills.8a08c7bebefd1a5e8a0e.js:1
P @ polyfills.8a08c7bebefd1a5e8a0e.js:1
(anonymous) @ polyfills.8a08c7bebefd1a5e8a0e.js:1
r @ runtime.772503e10c93ab63efc3.js:1
(anonymous) @ 2.2a8b5bc9585032a33c70.js:1

Travisfile

sudo: required
addons:
  ssh_known_hosts:
  - staging.com
  - production.com
language: node_js
node_js:
- '8'
before_script:
- nvm use 8.9.1
- npm install npm@latest -g
- npm install
script:
- ng build --prod
before_install:
- openssl aes-256-cbc -in ./deploy/deploy_rsa.enc -out ./deploy/deploy_rsa -d
- chmod 400 ./deploy/deploy_rsa
deploy:
- provider: script
  skip_cleanup: true
  script: bash ./deploy/deploy-qa.sh
  on:
    branch: develop
- provider: script
  skip_cleanup: true
  script: bash ./deploy/deploy-prod.sh
  on:
    branch: master
    tags: true
notifications:
  email: false
cache:
  npm: true

部署脚本包含

 #!/usr/bin/env bash
 rsync -av -e "ssh -i ./deploy/deploy_rsa" ./dist/frontend/ ubuntu@staging.com:~/frontend
 ssh -i ./deploy/deploy_rsa ubuntu@staging.com "sudo rm -rf /var/www/frontend.cf/*"
 ssh -i ./deploy/deploy_rsa ubuntu@staging.com "sudo cp -r /home/ubuntu/frontend/* /var/www/frontend.cf/"
 ssh -i ./deploy/deploy_rsa ubuntu@staging.com "sudo chown -R www-data:www-data /var/www/frontend.cf/*"
 ssh -i ./deploy/deploy_rsa ubuntu@staging.com "sudo rm -fr /home/ubuntu/frontend"

我尝试调试travis构建并运行部署脚本,部署成功,但页面加载失败。

0 个答案:

没有答案