简体   繁体   English

将Angular2应用程序部署到Github错误:events.js throw er; //未处理的“错误”事件

[英]Deploying Angular2 App to Github Error : events.js throw er; // Unhandled 'error' event

I am trying to deploy an angular2(sample app created from command "ng new my-app" ) app to GitHub using angular-cli-ghpages as mentioned in 我正在尝试使用angular-cli-ghpages将angular2(从命令“ ng new my-app”创建的示例应用)应用部署到GitHub,如

http://crookedcode.com/2017/02/24/deployment-of-angular2-app-to-github-pages/ http://crookedcode.com/2017/02/24/deployment-of-angular2-app-to-github-pages/

But whenever I am executing the command I getting error as below, 但是,每当我执行命令时,都会出现如下错误,

在此处输入图片说明

After searching on Google, I could see suggestion that it might be issue with node. 在Google上搜索之后,我可以看到有关节点可能存在问题的建议。 But I am not clear about what needs to done to fix this. 但是我不清楚需要做什么来解决此问题。

my node version is v9.2.0 我的节点版本是v9.2.0

npm version is 5.5.1 npm版本是5.5.1

Please help. 请帮忙。

You Can follow these steps to deploy the files to gh-pages 您可以按照以下步骤将文件部署到gh页

Angular 2 Deployment in Github Pages Github页面中的Angular 2部署

Testing Deployment of Angular2 Webpack in ghpages 在ghpages中测试Angular2 Webpack的部署

First get all relevant the files from the Dist Folder of your application 首先从应用程序的Dist文件夹中获取所有相关文件

for me it was the css files in the assets folder main.bundle.js polyfills.bundle.js vendor.bundle.js 对我来说,这是资产文件夹main.bundle.js polyfills.bundle.js vendor.bundle.js中的css文件

Then push this files in the repo which you have created. 然后将此文件推送到您创建的仓库中。

1 -- If you want the application to run on the root directory - create a special repo with the name [yourgithubusername].github.io and push these files in the master branch 1-如果您希望应用程序在根目录上运行,请创建一个名称为[yourgithubusername] .github.io的特殊存储库,并将这些文件推送到master分支中

2 -- Where as if you want to create these page in the sub directory of in a different brach other than that of the root , create a branch gh-pages and push these files in that branch. 2-好像您要在根目录之外的其他分支的子目录中创建这些页面一样,创建一个分支gh-pages并将这些文件推送到该分支中。

In both the cases the way we access these deployed pages will be different . 在这两种情况下,我们访问这些已部署页面的方式都会有所不同。

For the First Case it will be https://[yourgithubusername].github.io and for the second case it will be [yourgithubusername].github.io/[Repo name]. 对于第一种情况,它将是https:// [yourgithubusername] .github.io ,对于第二种情况,它将是[yourgithubusername] .github.io / [Repo name]。

If Suppose you want to deploy it using the second case make sure to change the base url pf the index.html file in the dist as all the route mappings depend on the path you give and it should be set to [/branchname]. 如果假设您要使用第二种情况进行部署,请确保更改dist中的index.html文件的基本URL,因为所有路由映射都取决于您提供的路径,并且应将其设置为[/ branchname]。

Link to this page

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM