使用 angular-cli-ghpages 将 Angular4 部署到 ghpages 时出错
Error deploying Angular4 to ghpages using angular-cli-ghpages
我正在尝试将一个简单的 Angular 4 应用程序部署到 gh-pages。我尝试了几种方法,似乎 angular-cli-ghpages 是最新的方法。
我已按照 npm angular-cli-ghpages page 上的说明进行操作 angular-cli-ghpages page。
首先我安装成功angular-cli-ghpages,
$ sudo npm i -g angular-cli-ghpages
如果没有 sudo,此命令将无法运行。
接下来我创建了 dist 文件夹并设置了 base-href,
$ ng build --prod --base-href “https://shanegibney.github.io/mathapp/”
然后我部署了
$ngh
但这会产生错误,
输出可以在下图中看到,
运行 angular-cli-ghpages 而不是 ngh 会产生相同的错误,
我正在使用以下版本,
npm 3.10.10
angular-cli-ghpages ^0.5.1
node 6.9.4(这里不是真正的问题)
谢谢
我通过在 package.json、
中的脚本对象末尾添加以下内容解决了这个问题
"scripts": {
"deploy": "ng build --prod --base-href
https://shanegibney.github.io/mathapp/ && angular-cli-ghpages --branch
gh-pages"
}
然后是运行,
$sudo npm run deploy
所以似乎需要的是'--b运行ch gh-pages'作为一个选项,但在 angular- 的 npm 页面上没有任何建议cli-ghpages.
请注意,如果 运行 这些命令单独执行而不经过 package.json 我发现它不起作用,
$ sudo ng build --prod --base-href https://shanegibney.github.io/mathapp/
$ sudo angular-cli-ghpages --branch gh-pages
得到了 blog post on shermandigital.com
的帮助
我上周将 Angular2 应用程序部署到 gh-pages(Live)。但我没有使用
angular-cli-ghpages 页面。
使用了这些依赖项 -
- @angular/cli": "^1.2.0
- @angular/compiler-cli": "^2.3.1
现在需要将我们的项目构建为迷你文件 css 和 js。
只需 运行 您 angular 项目中的这段代码
ng build --prod--aot --base-href "https://username.github.io/repo-name/"
如果编译时遇到问题
在 angular-cli.json 文件
中替换此代码
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
到
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
编译成功后(100%)
只需 运行 这个命令部署到 gh-pahes
ngh --message "Deploy gh pages"
我 运行 作为超级用户执行该命令并且它起作用了。尝试一下。如果没有,运行 带有 --no-silent 的命令以获取更多详细信息。示例:
sudo angular-cli-ghpages --no-silent
git 推送 origin master 之后
gh - 页面部署
第 1 步:"ng build --prod --base-href https://username.github.io/project-name/"
第 2 步:"ngh --dir dist/project-name"
替换项目名称
和 github 用户名,项目名称
的用户名
我正在尝试将一个简单的 Angular 4 应用程序部署到 gh-pages。我尝试了几种方法,似乎 angular-cli-ghpages 是最新的方法。
我已按照 npm angular-cli-ghpages page 上的说明进行操作 angular-cli-ghpages page。
首先我安装成功angular-cli-ghpages,
$ sudo npm i -g angular-cli-ghpages
如果没有 sudo,此命令将无法运行。
接下来我创建了 dist 文件夹并设置了 base-href,
$ ng build --prod --base-href “https://shanegibney.github.io/mathapp/”
然后我部署了
$ngh
但这会产生错误,
输出可以在下图中看到,
运行 angular-cli-ghpages 而不是 ngh 会产生相同的错误,
我正在使用以下版本,
npm 3.10.10
angular-cli-ghpages ^0.5.1
node 6.9.4(这里不是真正的问题)
谢谢
我通过在 package.json、
中的脚本对象末尾添加以下内容解决了这个问题"scripts": {
"deploy": "ng build --prod --base-href
https://shanegibney.github.io/mathapp/ && angular-cli-ghpages --branch
gh-pages"
}
然后是运行,
$sudo npm run deploy
所以似乎需要的是'--b运行ch gh-pages'作为一个选项,但在 angular- 的 npm 页面上没有任何建议cli-ghpages.
请注意,如果 运行 这些命令单独执行而不经过 package.json 我发现它不起作用,
$ sudo ng build --prod --base-href https://shanegibney.github.io/mathapp/
$ sudo angular-cli-ghpages --branch gh-pages
得到了 blog post on shermandigital.com
的帮助我上周将 Angular2 应用程序部署到 gh-pages(Live)。但我没有使用
angular-cli-ghpages 页面。
使用了这些依赖项 -
- @angular/cli": "^1.2.0
- @angular/compiler-cli": "^2.3.1
现在需要将我们的项目构建为迷你文件 css 和 js。 只需 运行 您 angular 项目中的这段代码
ng build --prod--aot --base-href "https://username.github.io/repo-name/"
如果编译时遇到问题 在 angular-cli.json 文件
中替换此代码"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
到
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
编译成功后(100%) 只需 运行 这个命令部署到 gh-pahes
ngh --message "Deploy gh pages"
我 运行 作为超级用户执行该命令并且它起作用了。尝试一下。如果没有,运行 带有 --no-silent 的命令以获取更多详细信息。示例:
sudo angular-cli-ghpages --no-silent
git 推送 origin master 之后 gh - 页面部署 第 1 步:"ng build --prod --base-href https://username.github.io/project-name/"
第 2 步:"ngh --dir dist/project-name"
替换项目名称 和 github 用户名,项目名称
的用户名