一、安装配置Nodejs环境,已经使用express搭建web框架
2019-01-24 11:51
585 查看
参考:https://blog.csdn.net/qq_38209578/article/details/82593591
参考:https://www.cnblogs.com/learnings/p/7372718.html
一、查看npm的版本
输入:cnpm -v和输入npm -v
[code]C:\Users\shenzhu>cnpm -v 'cnpm' 不是内部或外部命令,也不是可运行的程序 或批处理文件。 C:\Users\shenzhu>npm -v 3.8.9
二、使用npm install express -g命令来安装express插件
输入:npm install express -g
[code]C:\Users\shenzhu>npm install express -g C:\Users\shenzhu\AppData\Roaming\npm `-- express@4.16.4 +-- accepts@1.3.5 | +-- mime-types@2.1.21 | | `-- mime-db@1.37.0 | `-- negotiator@0.6.1 +-- array-flatten@1.1.1 +-- body-parser@1.18.3 | +-- bytes@3.0.0 | +-- http-errors@1.6.3 | | `-- inherits@2.0.3 | +-- iconv-lite@0.4.23 | | `-- safer-buffer@2.1.2 | `-- raw-body@2.3.3 +-- content-disposition@0.5.2 +-- content-type@1.0.4 +-- cookie@0.3.1 +-- cookie-signature@1.0.6 +-- debug@2.6.9 | `-- ms@2.0.0 +-- depd@1.1.2 +-- encodeurl@1.0.2 +-- escape-html@1.0.3 +-- etag@1.8.1 +-- finalhandler@1.1.1 | `-- unpipe@1.0.0 +-- fresh@0.5.2 +-- merge-descriptors@1.0.1 +-- methods@1.1.2 +-- on-finished@2.3.0 | `-- ee-first@1.1.1 +-- parseurl@1.3.2 +-- path-to-regexp@0.1.7 +-- proxy-addr@2.0.4 | +-- forwarded@0.1.2 | `-- ipaddr.js@1.8.0 +-- qs@6.5.2 +-- range-parser@1.2.0 +-- safe-buffer@5.1.2 +-- send@0.16.2 | +-- destroy@1.0.4 | `-- mime@1.4.1 +-- serve-static@1.13.2 +-- setprototypeof@1.1.0 +-- statuses@1.4.0 +-- type-is@1.6.16 | `-- media-typer@0.3.0 +-- utils-merge@1.0.1 `-- vary@1.1.2
三、使用express新建项目
输入:express myapp
注:myapp是项目名称可以自己换,若是还没有安装express命令会提示如下:
[code]C:\Users\shenzhu>express myapp 'express' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
1、安装命令插件
输入:npm install -g express-generator
[code]C:\Users\shenzhu>npm install -g express-generator C:\Users\shenzhu\AppData\Roaming\npm\express -> C:\Users\shenzhu\AppData\Roaming\npm\node_modules\express-generator\bin\express-cli.js C:\Users\shenzhu\AppData\Roaming\npm `-- express-generator@4.16.0 +-- commander@2.13.0 +-- ejs@2.5.7 +-- minimatch@3.0.4 | `-- brace-expansion@1.1.11 | +-- balanced-match@1.0.0 | `-- concat-map@0.0.1 +-- mkdirp@0.5.1 | `-- minimist@0.0.8 `-- sorted-object@2.0.1
2、新建myAPP项目
安装完命令之后,重新输入:express myapp,就可以新建项目
[code] C:\Users\shenzhu>express myapp warning: the default view engine will not be jade in future releases warning: use `--view=jade' or `--help' for additional options create : myapp\ create : myapp\public\ create : myapp\public\javascripts\ create : myapp\public\images\ create : myapp\public\stylesheets\ create : myapp\public\stylesheets\style.css create : myapp\routes\ create : myapp\routes\index.js create : myapp\routes\users.js create : myapp\views\ create : myapp\views\error.jade create : myapp\views\index.jade create : myapp\views\layout.jade create : myapp\app.js create : myapp\package.json create : myapp\bin\ create : myapp\bin\www change directory: > cd myapp install dependencies: > npm install run the app: > SET DEBUG=myapp:* & npm start
四、新建好的项目的目录
注意:建好的项目会保存在什么地方呢?
如上面的myapp项目,是在C:\Users\shenzhu这种目录下,所以最好是新建好自己的项目目录,然后进入到自己的项目目录下,再执行express的相关命令,这样项目工程就会创建在你自己建的目录下了
五、安装依赖模块
输入:app>npm install
[code]C:\Users\shenzhu\NodeJSProject\app>npm install npm WARN deprecated jade@1.11.0: Jade has been renamed to pug, please install the latest version of pug instead of ja npm WARN deprecated transformers@2.1.0: Deprecated, use jstransformer npm WARN deprecated constantinople@3.0.2: Please update to at least constantinople 3.1.1 app@0.0.0 C:\Users\shenzhu\NodeJSProject\app +-- cookie-parser@1.4.3 | +-- cookie@0.3.1 | `-- cookie-signature@1.0.6 +-- debug@2.6.9 | `-- ms@2.0.0 +-- express@4.16.4 | +-- accepts@1.3.5 | | +-- mime-types@2.1.21 | | | `-- mime-db@1.37.0 | | `-- negotiator@0.6.1 | +-- array-flatten@1.1.1 | +-- body-parser@1.18.3 | | +-- bytes@3.0.0 | | +-- iconv-lite@0.4.23 | | | `-- safer-buffer@2.1.2 | | `-- raw-body@2.3.3 | +-- content-disposition@0.5.2 | +-- content-type@1.0.4 | +-- depd@1.1.2 | +-- encodeurl@1.0.2 | +-- escape-html@1.0.3 | +-- etag@1.8.1 | +-- finalhandler@1.1.1 | | `-- unpipe@1.0.0 | +-- fresh@0.5.2 | +-- merge-descriptors@1.0.1 | +-- methods@1.1.2 | +-- on-finished@2.3.0 | | `-- ee-first@1.1.1 | +-- parseurl@1.3.2 | +-- path-to-regexp@0.1.7 | +-- proxy-addr@2.0.4 | | +-- forwarded@0.1.2 | | `-- ipaddr.js@1.8.0 | +-- qs@6.5.2 | +-- range-parser@1.2.0 | +-- safe-buffer@5.1.2 | +-- send@0.16.2 | | +-- destroy@1.0.4 | | `-- mime@1.4.1 | +-- serve-static@1.13.2 | +-- setprototypeof@1.1.0 | +-- statuses@1.4.0 | +-- type-is@1.6.16 | | `-- media-typer@0.3.0 | +-- utils-merge@1.0.1 | `-- vary@1.1.2 +-- http-errors@1.6.3 | `-- inherits@2.0.3 +-- jade@1.11.0 | +-- character-parser@1.2.1 | +-- clean-css@3.4.28 | | +-- commander@2.8.1 | | | `-- graceful-readlink@1.0.1 | | `-- source-map@0.4.4 | | `-- amdefine@1.0.1 | +-- commander@2.6.0 | +-- constantinople@3.0.2 | | `-- acorn@2.7.0 | +-- jstransformer@0.0.2 | | +-- is-promise@2.1.0 | | `-- promise@6.1.0 | | `-- asap@1.0.0 | +-- mkdirp@0.5.1 | | `-- minimist@0.0.8 | +-- transformers@2.1.0 | | +-- css@1.0.8 | | | +-- css-parse@1.0.4 | | | `-- css-stringify@1.0.5 | | +-- promise@2.0.0 | | | `-- is-promise@1.0.1 | | `-- uglify-js@2.2.5 | | +-- optimist@0.3.7 | | | `-- wordwrap@0.0.3 | | `-- source-map@0.1.43 | +-- uglify-js@2.8.29 | | +-- source-map@0.5.7 | | +-- uglify-to-browserify@1.0.2 | | `-- yargs@3.10.0 | | +-- camelcase@1.2.1 | | +-- cliui@2.1.0 | | | +-- center-align@0.1.3 | | | | +-- align-text@0.1.4 | | | | | +-- kind-of@3.2.2 | | | | | | `-- is-buffer@1.1.6 | | | | | +-- longest@1.0.1 | | | | | `-- repeat-string@1.6.1 | | | | `-- lazy-cache@1.0.4 | | | +-- right-align@0.1.3 | | | `-- wordwrap@0.0.2 | | +-- decamelize@1.2.0 | | `-- window-size@0.1.0 | +-- void-elements@2.0.1 | `-- with@4.0.3 | +-- acorn@1.2.2 | `-- acorn-globals@1.0.9 `-- morgan@1.9.1 +-- basic-auth@2.0.1 `-- on-headers@1.0.1
六、使用npm start 运行项目
输入:npm start
1、刚开始报了下面的的错误
[code]npm ERR! Windows_NT 6.1.7601 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start" npm ERR! node v6.2.0 npm ERR! npm v3.8.9 npm ERR! code ELIFECYCLE npm ERR! app@0.0.0 start: `node ./bin/www` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the app@0.0.0 start script 'node ./bin/www'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the app package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node ./bin/www npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs app npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls app npm ERR! There is likely additional logging output above. npm ERR! Please include the following file with any support request: npm ERR! C:\Users\shenzhu\NodeJSProject\app\npm-debug.log C:\Users\shenzhu\NodeJSProject\app>
从上面的提示看,说可能是npm或者nodejs不是最新版,但是我的npm是最新版的,所以我就重新
安装了一下nodejs,到官网里面又下载了一个最新的版本的nodejs,重新安装完成之后,就OK了,如下:
[code]C:\Users\shenzhu\NodeJSProject\app>npm start > app@0.0.0 start C:\Users\shenzhu\NodeJSProject\app > node ./bin/www
七、node express新建的项目没有.idea
这个如果使用ide的话就有
相关文章推荐
- Web前端环境搭建篇之--安装配置NodeJS环境
- 服务器搭建javaWeb开发环境—svn安装与配置以及使用
- nodejs安装,配置环境,使用express建立一个新项目
- nodejs环境搭建与express安装配置
- 搭建python2.7环境、python与eclipse配置、以及安装Flask框架,建立web项目
- IDEA安装与破解/IDEA汉化版安装/IDEA + Maven + SpringMVC + Hibernate集成环境搭建/框架配置以及IDEA快捷使用
- nodejs安装,配置环境,使用express建立一个新项目
- 搭建PXE全自动系统安装配置环境(分别使用CentOS和Ubuntu做安装源)
- Android NDK r8 Cygwin CDT 在window下开发环境搭建 安装配置与使用 详细图文讲解
- (一)nodejs开发环境搭建: 安装nodejs以及配置npm
- Linux下 php环境安装、配置composer,使用composer安装laravel、zan等框架
- Android Studio安装配置、环境搭建详细步骤及基本使用
- android 最新 NDK r8 在window下开发环境搭建 安装配置与使用 详细图文讲解,完整实际配置过程记录
- Linux下 php环境安装、配置composer,使用composer安装laravel、zan等框架
- nodejs安装与配置(express生成简单的web服务器)
- android 最新 NDK r8 在window下开发环境搭建 安装配置与使用 详细图文讲解,完整实际配置过程记录(原创)
- 使用SSM框架搭建web项目配置步骤
- Python web框架Django学习(1)——在win7 64bit下配置开发环境Django:一个可以使Web开发工作愉快并且高效的Web开发框架。 使用Django,使你能够以最小的代价构建和
- 手把手教你在centos下编译安装配置高性能web服务器环境nginx+php(fast-cgi)+mysql等/适合小内存vps使用
- 【转】android 最新 NDK r8 在window下开发环境搭建 安装配置与使用 详细图文讲解,完整实际配置过程记录(原创)