NodeJs-- 新建项目实例

  1. 安装Nodejs: 下载地址:http://nodejs.org/download/
  2. 设置环境变量,例如我将nodejs装在D:/program文件夹下,则设以下为系统环境变量

    [html]view plaincopyprint?

    1. D:\Program\nodejs
  3. 安装Express开发框架:

    [html]view plaincopyprint?

    1. //命令行输入命令
    2. npm install -g express
    3. npm install -g express-generator
  4. 新建项目

    [html]view plaincopyprint?

    1. //命令行输入命令
    2. express -t ejs newsproject
  5. 按照提示进入项目目录,运行npm安装

    [html]view plaincopyprint?

    1. //进入项目目录
    2. cd newsproject
    3. //输入命令安装
    4. npm install
  6. 运行项目

    [html]view plaincopyprint?

    1. //项目目录下运行命令
    2. node app.js
  7. 浏览器访问:http://127.0.0.1:3000/即可见nodejs站点页面,页面输出:Express