crossplatform---Nodejs in Visual Studio Code 01.简单介绍Nodejs
1.开始
作者自己:开发人员,Asp.Net , html / js , restful , memcached , oracle ,windows , iis
目标读者:供自己以后回顾
2.我看Nodejs
一个运行时语言,可以使用javascript编写网站程序;
可以运行在windows和linux上,并且不需要iis或tomcat就能够独立运行;
写一些基于业务的API很方便,适合做项目;
据说可以处理高并发等等各种高能,但是我现在并不会;
3.安装Nodejs
- Nodejs : https://nodejs.org
- NPM : 安装Nodejs后,可以在CMD中使用NPM命令,主要用来安装扩展,对于C#人来说就是相当于Nuget的东西,帮你下载并应用类库。
安装Windows x64的,安装完成后检查
1
2
3
4
|
$ node – v v4.4.2 $ npm - v 2.15.0 |
设置全局目录
- 全局模块:node_global
- 缓存目录:node_cache
1
2
|
$ npm config set prefix "C:\Program Files\nodejs" $ npm config set cache "C:\Program Files\nodejs\node_cache" |
设置环境变量
我的电脑→属性→高级→环境变量
1
|
NODE_PATH :C:\Program Files\nodejs\node_modules |
4.安装Express
- Express: 使用Nodejs进行Web开发的组件,需要使用NPM进行安装;
- Express-Generator:安装以后可以在CMD中使用Express命令来新建示例代码;
- -g:将组件安装至全局,所有Nodejs项目可以不用将组件安装至本地文件夹;
- --proxy:爬楼梯,可选参数,你懂的;
1
2
|
$ npm install express -g --proxy http: //127 .0.0.1:1080 $ npm install express-generator -g --proxy http: //127 .0.0.1:1080 |
打开项目管理目录Visual Studio Code新建一个Nodejs示例程序myapp
1
2
3
4
5
6
7
8
9
10
11
|
$ cd D:\Libraries\Documents\Visual Studio Code $ express myapp create : myapp create : myapp /package .json ...... install dependencies: > cd myapp && npm install run the app: > SET DEBUG=myapp:* & npm start |
package.json :项目描述文件,myapp项目引用了哪些第三方组件可以在这里找到
- name:项目名称
- version:版本
- scripts.start:启动文件,启动类,bin/www其实是一个启动类
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
{ "name" : "myapp" , //项目名称 "version" : "0.0.0" , //项目版本 "private" : true , "scripts" : { "start" : "node ./bin/www" //项目启动文件 }, "dependencies" : { "body-parser" : "~1.13.2" , "cookie-parser" : "~1.3.5" , "debug" : "~2.2.0" , "express" : "~4.13.1" , "jade" : "~1.11.0" , "morgan" : "~1.6.1" , "serve-favicon" : "~2.3.0" } } |
安装依赖组件,package.json里面的依赖组件如果不安装则无法启动项目,安装完成后myapp\node_modules下将多了很多文件,作用和DLL差不多
1
2
3
4
5
6
7
8
9
|
$ cd D:\Libraries\Documents\Visual Studio Code\myapp $ npm install debug@2.2.0 node_modules\debug └── ms@0.7.1 serve-favicon@2.3.0 node_modules\serve-favicon ├── fresh@0.3.0 ... |
程序可以运行了。
1
2
3
|
$ npm start > myapp@0.0.0 start d:\Libraries\Documents\Visual Studio Code\myapp > node . /bin/www |
打开Visual Studio Code,打开myapp目录,点F5,选择node.js环境调试应用
http://www.cnblogs.com/mengkzhaoyun/p/5354634.html
crossplatform---Nodejs in Visual Studio Code 01.简单介绍Nodejs的更多相关文章
- Nodejs in Visual Studio Code 01.简单介绍Nodejs
1.开始 作者自己:开发人员,Asp.Net , html / js , restful , memcached , oracle ,windows , iis 目标读者:供自己以后回顾 2.我看No ...
- Nodejs in Visual Studio Code 14.IISNode与IIS7.x
1.开始 部署IISNode环境请参考:Nodejs in Visual Studio Code 08.IIS 部署Nodejs程序请参考:Nodejs in Visual Studio Code 1 ...
- Nodejs in Visual Studio Code 11.前端工程优化
1.开始 随着互联网技术的发展,企业应用里到处都是B/S设计,我有幸经历了很多项目有Asp.Net的,有Html/js的,有Silverlight的,有Flex的.很遗憾这些项目很少关注前端优化的问题 ...
- Nodejs in Visual Studio Code 10.IISNode
1.开始 Nodejs in Visual Studio Code 08.IIS : http://www.cnblogs.com/mengkzhaoyun/p/5410185.html 参考此篇内容 ...
- Nodejs in Visual Studio Code 04.Swig模版
1.开始 设置Node_Global:npm config set prefix "C:\Program Files\nodejs" Express组件:npm install e ...
- Visual Studio Code 的简单试用体验
首先对Visual Studio Code做一个大概的介绍.首先明确一下,这个Visual Studio Code(以下简称 vscode)是一个带GUI的代码编辑器,也就是只能完成简单的代码编辑功能 ...
- Nodejs in Visual Studio Code 07.学习Oracle
1.开始 Node.js:https://nodejs.org OracleDB: https://github.com/oracle/node-oracledb/blob/master/INSTAL ...
- Nodejs in Visual Studio Code 02.学习Nodejs
1.开始 源码下载:https://github.com/sayar/NodeMVA 在线视频:https://mva.microsoft.com/en-US/training-courses/usi ...
- Nodejs in Visual Studio Code 08.IIS
1.开始 本文部分内容均转载自文章: http://www.hanselman.com/blog/InstallingAndRunningNodejsApplicationsWithinIISOnWi ...
随机推荐
- 【Codeforces Round #185 (Div. 2) A】 Whose sentence is it?
[链接] 链接 [题意] 告诉你每句话; 然后每句话是谁说的和开头与结尾的一段字符串有关. [题解] 一个一个判断就好; 注意大小<5的情况 [错的次数] 在这里输入错的次数 [反思] 在这里输 ...
- JSP自己定义标签
JSP自己定义标签 API文档: http://docs.oracle.com/javaee/7/api/ watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZ ...
- JS和PHP和JAVA的正则表达式的区别(java没有分解符,java中的转义字符是\\)
JS和PHP和JAVA的正则表达式的区别(java没有分解符,java中的转义字符是\\) 一.总结 js正则:var patrn=/^[0-9]{1,20}$/; php正则:$pattern='/ ...
- IOS的后台执行
写在前面给大家推荐一个不错的站点 www.joblai.com 本文章由央广传媒开发部 冯宝瑞整理.哈哈 http://www.cocoachina.com/bbs/read.php? tid=14 ...
- [React] Update State in React with Ramda's Evolve
In this lesson we'll take a stateful React component and look at how we can refactor our setState ca ...
- synology
入手群晖261J无法正常安装DSM 错误代码38 求教各位恶魔https://www.chiphell.com/thread-1599081-1-1.html(出处: Chiphell - 分享与交流 ...
- android生成分享长图而且加入全图水印
尊重他人的劳动成果.转载请标明出处:http://blog.csdn.net/gengqiquan/article/details/65938021. 本文出自:[gengqiquan的博客] 领导近 ...
- 机器学习: Softmax Classifier (三个隐含层)
程序实现 softmax classifier, 含有三个隐含层的情况.activation function 是 ReLU : f(x)=max(0,x) f1=w1x+b1 h1=max(0,f1 ...
- C/C++ 笔试、面试题目大汇总2
http://www.cnblogs.com/fangyukuan/archive/2010/09/18/1830493.html 一.找错题 试题1: void test1() { charstri ...
- [React] displayName for stateless component
We can use 'displayName' on component to change its component tag in dev tool: import React from 're ...