Travis CI未能使用Angular Material

时间:2018-04-24 03:14:31

标签: angular angular5 travis-ci angular-material2

我无法让我的travis ci构建通过。这是我第一次使用Travis和Angular 5,但我已经阅读了文档,但似乎无法弄清楚我缺少什么,很确定它很简单。 ng build在本地传递,只在构建中失败。我正在考虑一些我如何在构建中不包含角度材料但在谷歌上找不到任何需要包含它或如何包含它的内容。我已经包含了.travis.yml和错误堆栈,感谢任何帮助。

构建错误: ERROR in ./src/styles.css Module build failed: Error: Can't resolve '@angular/material/prebuilt-themes/indigo-pink.css' in '/home/travis/build/jearl4/portfolio/src' at onError (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/Resolver.js:61:15) at loggingCallbackWrapper (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19) at runAfter (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/Resolver.js:158:4) at innerCallback (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/Resolver.js:146:3) at loggingCallbackWrapper (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19) at next (/home/travis/build/jearl4/portfolio/node_modules/tapable/lib/Tapable.js:252:11) at /home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:40:4 at loggingCallbackWrapper (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19) at runAfter (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/Resolver.js:158:4) at innerCallback (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/Resolver.js:146:3) at loggingCallbackWrapper (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19) at next (/home/travis/build/jearl4/portfolio/node_modules/tapable/lib/Tapable.js:252:11) at innerCallback (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/Resolver.js:144:11) at loggingCallbackWrapper (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19) at next (/home/travis/build/jearl4/portfolio/node_modules/tapable/lib/Tapable.js:249:35) at resolver.doResolve.createInnerCallback (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:44:6) @ multi ./src/styles.css ERROR in ./src/styles.css Module build failed: ModuleBuildError: Module build failed: Error: Can't resolve '@angular/material/prebuilt-themes/indigo-pink.css' in '/home/travis/build/jearl4/portfolio/src' at onError (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/Resolver.js:61:15) at loggingCallbackWrapper (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19) at runAfter (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/Resolver.js:158:4) at innerCallback (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/Resolver.js:146:3) at loggingCallbackWrapper (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19) at next (/home/travis/build/jearl4/portfolio/node_modules/tapable/lib/Tapable.js:252:11) at /home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:40:4 at loggingCallbackWrapper (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19) at runAfter (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/Resolver.js:158:4) at innerCallback (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/Resolver.js:146:3) at loggingCallbackWrapper (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19) at next (/home/travis/build/jearl4/portfolio/node_modules/tapable/lib/Tapable.js:252:11) at innerCallback (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/Resolver.js:144:11) at loggingCallbackWrapper (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19) at next (/home/travis/build/jearl4/portfolio/node_modules/tapable/lib/Tapable.js:249:35) at resolver.doResolve.createInnerCallback (/home/travis/build/jearl4/portfolio/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:44:6) at runLoaders (/home/travis/build/jearl4/portfolio/node_modules/webpack/lib/NormalModule.js:195:19) at /home/travis/build/jearl4/portfolio/node_modules/loader-runner/lib/LoaderRunner.js:364:11 at /home/travis/build/jearl4/portfolio/node_modules/loader-runner/lib/LoaderRunner.js:230:18 at context.callback (/home/travis/build/jearl4/portfolio/node_modules/loader-runner/lib/LoaderRunner.js:111:13) at Promise.resolve.then.then.catch (/home/travis/build/jearl4/portfolio/node_modules/postcss-loader/lib/index.js:198:71) at process._tickCallback (internal/process/next_tick.js:103:7) @ ./src/styles.css @ multi ./src/styles.css ERROR in app/material.module.ts(5,15): Error during template compile of 'MaterialModule' Could not resolve @angular/material relative to /home/travis/build/jearl4/portfolio/src/app/material.module.ts.. src/app/material.module.ts(3,51): error TS2307: Cannot find module '@angular/material'.

.travis.yml

sudo: required  
dist: trusty

language: node_js
node_js:
  - "6.9"

before_install:  
 - export CHROME_BIN=/usr/bin/google-chrome
 - export DISPLAY=:99.0 
 - sh -e /etc/init.d/xvfb start
 - sudo apt-get update
 - sudo apt-get install -y libappindicator1 fonts-liberation
 - wget https://dl.google.com/linux/direct/google-chrome- 
stable_current_amd64.deb
 - sudo dpkg -i google-chrome*.deb

before_script:
  - npm install -g firebase-tools
  - npm install -g @angular/cli

script:
  - ng build --prod

after_success:
  - firebase deploy --token $FIREBASE_TOKEN

notifications:
  email:
    on_failure: change
    on_success: change

1 个答案:

答案 0 :(得分:1)

我认为你错过了项目模块的安装。尝试将以下行添加到before_script部分:

- npm install

如果你在package.json中有正确的依赖项,它将自动安装,如果没有,那么你需要将angular-material及其依赖项添加到package.json。可以通过运行以下命令来完成:

npm install --save @angular/material @angular/cdk

不要忘记将更改提交到存储库中。