angular.js - angular静态网页 怎么部署到node上面

浏览:31日期:2023-01-26

问题描述

我有一个可以在Apache上跑的静态angular项目,想在想把它迁移到node环境里去,不知道该怎么写node的server.js和page.json.

问题解答

回答1:

用KOA这么写就行

var koa = require(’koa’);var serve = require(’koa-static’);var path = require(’path’);// KOA框架var app = module.exports = koa();// 错误处理app.on(’error’, function(err, ctx){ console.log(err.message);});// 静态中间件app.use(serve(path.join(__dirname, ’public’)));// 监听端口if (!module.parent){ app.listen(3000); logger.info(’My Website run on 3000...’);}

/app.js/public/index.html //angular入口

回答2:

用 nokit,一行命令:

$ cd <angular项目目录>$ nokit start <port> -public:./

更详细的用法,查看 http://nokit.org

回答3:

直接放在静态文件里面吧,使用后直接访问静态页面地址就行,这个游戏就是这么搞的http://tianmaying.com/app/collect-b/index.html

回答4:

express

回答5:

嘿嘿,试试sero-cli吧,第二项“Start a static web server for current working directory”,在你的angular项目根目录里使用这个命令,选第二项就可以了。

相关文章: