简体   繁体   中英

How to upload and run Angular applications on Firebase?

Firebase Hosting doesn't support Node.js but to install Angular, one has to use npm

npm install -g @angular/cli

Without npm, angular can't install and without Node.js, Angular app can't run. But because Firebase Hosting doesn't support Node.js, we can't upload Angular apps? This also means we can't run npm packages like lodash, underscore etc..

Now there's also AngularFire 2 which is installed using npm!

npm install firebase angularfire2 --save

So to use Angular with Firebase, I've to use npm but the apps created using Angular + Firebase cannot be uploaded on Firebase Hosting because it doesn't supports npm!

Is there any workaround to host Angular apps on Firebase?

Firebase hosting is designated for delivery of static files, ie it does not "support Node.js" in the sence that you cannot implement custom server-side code (on Firebase Hosting at least - see Firebase Cloud Functions for this).

Of course you can fully develop your app with NPM as long as its just a full client web-app. You then upload your build result (ie compiled JavaScript / TypeScript + HTML + Assets + ...) to Firebase Hosting.

You just cannot run server side code with Firebase Hosting.

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