अपने एंगुलर 2 ऐप को किसी प्रोडक्शन सर्वर, सबसे पहले और सबसे पहले तैनात करने के लिए, सुनिश्चित करें कि आपका ऐप आपके मशीन पर स्थानीय रूप से चलता हो।
Angular2 ऐप को नोड ऐप के रूप में भी तैनात किया जा सकता है।
इसलिए, नोड एंट्री पॉइंट फ़ाइल सर्वर बनाएं। js / app.js (मेरा उदाहरण एक्सप्रेस का उपयोग करता है)
var express = require('express'),
path = require('path'),
fs = require('fs');
var app = express();
var staticRoot = __dirname + '/';
app.set('port', (process.env.PORT || 3000));
app.use(express.static(staticRoot));
app.use(function(req, res, next){
// if the request is not html then move along
var accept = req.accepts('html', 'json', 'xml');
if(accept !== 'html'){
return next();
}
// if the request has a '.' assume that it's for a file, move along
var ext = path.extname(req.path);
if (ext !== ''){
return next();
}
fs.createReadStream(staticRoot + 'index.html').pipe(res);
});
app.listen(app.get('port'), function() {
console.log('app running on port', app.get('port'));
});
अपने पैकेज में एक निर्भरता के रूप में एक्सप्रेस भी जोड़ें । Json फ़ाइल।
फिर इसे अपने पसंदीदा वातावरण पर तैनात करें।
मैंने IIS पर तैनाती के लिए एक छोटा सा ब्लॉग एक साथ रखा है। लिंक का पालन करें