Github页面上的Angular 4应用程序 [英] Angular 4 application on Github Pages

查看:84
本文介绍了Github页面上的Angular 4应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的Angular (4)应用程序,我想在Github Pages上托管,从Angular CLI执行此操作的选项似乎已删除.有办法做到这一点吗?

I have a simple Angular (4) application which I want to host on Github Pages, the option to do this from Angular CLI seems removed. Is there a way to do this, if so how?

这是我的package.json

this is my package.json

{
  "name": "e-portfolio",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/cli": "^1.0.6",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.26",
    "@ngx-translate/core": "^6.0.1",
    "bootstrap": "^4.0.0-alpha.6",
    "core-js": "^2.4.1",
    "font-awesome": "^4.7.0",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "1.0.6",
    "@angular/compiler-cli": "^4.0.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.5.0",
    "typescript": "~2.2.0"
  }
}

当尝试使用ng build时,我收到此消息

When trying to use ng build I get this message

作为警告,在下一个版本中,我们将CLI npm软件包移至"@ angular/cli", 仅支持Node 6.9及更高版本.该软件包将被正式弃用 不久之后.

As a forewarning, we are moving the CLI npm package to "@angular/cli" with the next release, which will only support Node 6.9 and greater. This package will be officially deprecated shortly after.

要禁用此警告,请使用"ng set --global warnings.packageDeprecation = false".

To disable this warning use "ng set --global warnings.packageDeprecation=false".

您必须在angular-cli项目中才能使用构建命令.

You have to be inside an angular-cli project in order to use the build command.

我的调试日志

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using npm@3.10.10
3 info using node@v6.9.5
4 verbose stack Error: ENOENT: no such file or directory, open 'C:\Users\User\Documents\School\Portfolio\ePortfolio\package.json'
4 verbose stack     at Error (native)
5 verbose cwd C:\Users\User\Documents\School\Portfolio\ePortfolio
6 error Windows_NT 10.0.15063
7 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
8 error node v6.9.5
9 error npm  v3.10.10
10 error path C:\Users\User\Documents\School\Portfolio\ePortfolio\package.json
11 error code ENOENT
12 error errno -4058
13 error syscall open
14 error enoent ENOENT: no such file or directory, open 'C:\Users\User\Documents\School\Portfolio\ePortfolio\package.json'
15 error enoent ENOENT: no such file or directory, open 'C:\Users\User\Documents\School\Portfolio\ePortfolio\package.json'
15 error enoent This is most likely not a problem with npm itself
15 error enoent and is related to npm not being able to find a file.
16 verbose exit [ -4058, true ]

推荐答案

在使用此逗号ng build --prod --base-href "https://USERNAME.github.io/REPOSITORY_NAME/"

我转到名为ePortfolio的存储库,将其键入为eportfolio,似乎字母P必须是大写字母才能起作用.

I switched out to my repository which is called ePortfolio, I typed it in as eportfolio, It seems that the letter P had to be capital for it to work.

这篇关于Github页面上的Angular 4应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆