1、如果有安装了Express的,先卸载: npm uninstall -g express
2、安装指定版本: npm install -g [email protected]
3、查看版本: express -V(注意express -V中的V要大写,不然很多版本中会不识别)
4、express4.0版本后将命令工具分家出来了(项目地址:https://github.com/expressjs/generator),所以我们还需要安装一个命令工具,命令如下:npm install -g express-generator
5、用命令创建Express项目:express helloworld
6、创建好project之后还需要用npm进行添加依赖和启动:npm install,然后:npm start(不是node app.js),然后新创建的helloworld就已经运行在3000端口上
7、访问http://localhost:3000/就看到熟悉的页面了