Usman Farooq
Usman Farooq

Reputation: 13

How to run angular 2 build files on express.js

I want to run index.html and i get it from angular2 app after ng build.

I tried these two lines of code one by one but these are not working for me app.use(express.static(path.resolve(__dirname+'/public/index.html'))); app.use(express.static(path.resolve(__dirname+'/public')));

Any idea how to resolve this?

Your help will greatly appreciated

Upvotes: 1

Views: 62

Answers (1)

Chau Tran
Chau Tran

Reputation: 5088

I will assume you already have the correct path to your public folder and also the ng build builds out to the public folder with the same path.

Do: app.use(express.static(path.join(__dirname, 'public')));

Upvotes: 0

Related Questions