简体   繁体   中英

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

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. But I am not clear about what needs to done to fix this.

my node version is v9.2.0

npm version is 5.5.1

Please help.

You Can follow these steps to deploy the files to gh-pages

Angular 2 Deployment in Github Pages

Testing Deployment of Angular2 Webpack in ghpages

First get all relevant the files from the Dist Folder of your application

for me it was the css files in the assets folder main.bundle.js polyfills.bundle.js vendor.bundle.js

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

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.

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].

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].

Link to this page

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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