在你的windows上已经安装了node.js的基础上再安装express
安装express
第一步:执行 npm install -g express-generator
note:必须安装这个,不然创建express项目的时候会提示express命令没有找到
第二步:执行 npm install -g express
第三步:执行 express --version
note:'V'是大写的,如果express安装成功会显示版本号
以下几个重要的模块是需要与 express 框架一起安装的:
body-parser- node.js 中间件,用于处理 JSON, Raw, Text 和 URL 编码的数据。
cookie-parser- 这就是一个解析Cookie的工具。通过req.cookies可以取到传过来的cookie,并把它们转成对象。
multer- node.js 中间件,用于处理 enctype="multipart/form-data"(设置表单的MIME编码)的表单数据。
不知是否必须?
配置系统变量:
D:\Zhuang\nodejs\;
C:\Users\zhuangyefan\AppData\Roaming\npm;
C:\Users\zhuangyefan\AppData\Roaming\npm\node_modules
创建Express项目

Error: Cannot find module 'express' 是因为还要在项目文件夹安装一下


打开项目文件夹,进行开发 (默认监听端口是3000)

网友评论