nodejs01--什么是nodejs,nodejs的基本使用
nodejs使用范围
-直接在cmd命令行运行,在你的电脑上直接运行
-可以搭建一个web服务器(express,koa)
-一些基本的使用
-modules是如何工作的
-npm管理modules
-搭建一个web服务器。
wow,that is awesome
首先当然是下载nodejs的安装包,这里就不再演示了。nodejs官方
modules是如何工作的
建立两个js,moduler01.js moduler02.js
//moduler01js
var _= require('underscore');
var m = require('./modular02.js');
m();
console.log(_);
nodejs
{ [Function]
_: [Circular],
VERSION: '1.8.3',
iteratee: [Function],
forEach: [Function],
each: [Function],
collect: [Function],
map: [Function],
inject: [Function],
foldl: [Function],
reduce: [Function],
foldr: [Function],
reduceRight: [Function],
detect: [Function],
find: [Function],
select: [Function],
filter: [Function],
reject: [Function],
all: [Function],
every: [Function],
any: [Function],
some: [Function],
include: [Function],
includes: [Function],
contains: [Function],
invoke: [Function],
pluck: [Function],
where: [Function],
findWhere: [Function],
max: [Function],
min: [Function],
shuffle: [Function],
sample: [Function],
sortBy: [Function],
groupBy: [Function],
indexBy: [Function],
countBy: [Function],
toArray: [Function],
size: [Function],
partition: [Function],
take: [Function],
head: [Function],
first: [Function],
initial: [Function],
last: [Function],
drop: [Function],
tail: [Function],
rest: [Function],
compact: [Function],
flatten: [Function],
without: [Function],
unique: [Function],
uniq: [Function],
union: [Function],
intersection: [Function],
difference: [Function],
zip: [Function],
unzip: [Function],
object: [Function],
findIndex: [Function],
findLastIndex: [Function],
sortedIndex: [Function],
indexOf: [Function],
lastIndexOf: [Function],
range: [Function],
bind: [Function],
partial: [Function],
bindAll: [Function],
memoize: [Function],
delay: [Function],
defer: [Function],
throttle: [Function],
debounce: [Function],
wrap: [Function],
negate: [Function],
compose: [Function],
after: [Function],
before: [Function],
once: [Function],
keys: [Function],
allKeys: [Function],
values: [Function],
mapObject: [Function],
pairs: [Function],
invert: [Function],
methods: [Function],
functions: [Function],
extend: [Function],
assign: [Function],
extendOwn: [Function],
findKey: [Function],
pick: [Function],
omit: [Function],
defaults: [Function],
create: [Function],
clone: [Function],
tap: [Function],
isMatch: [Function],
isEqual: [Function],
isEmpty: [Function],
isElement: [Function],
isArray: [Function: isArray],
isObject: [Function],
isArguments: [Function],
isFunction: [Function],
isString: [Function],
isNumber: [Function],
isDate: [Function],
isRegExp: [Function],
isError: [Function],
isFinite: [Function],
isNaN: [Function],
isBoolean: [Function],
isNull: [Function],
isUndefined: [Function],
has: [Function],
noConflict: [Function],
identity: [Function],
constant: [Function],
noop: [Function],
property: [Function],
propertyOf: [Function],
matches: [Function],
matcher: [Function],
times: [Function],
random: [Function],
now: [Function: now],
escape: [Function],
unescape: [Function],
result: [Function],
uniqueId: [Function],
templateSettings:
{ evaluate: /<%([\s\S]+?)%>/g,
interpolate: /<%=([\s\S]+?)%>/g,
escape: /<%-([\s\S]+?)%>/g },
template: [Function],
chain: [Function],
mixin: [Function] }
//moduler02.js
module.exports = function(){
console.log('nodejs');
}
npm管理modules
npm init //初始化npm管理,生产package.json
{
"name": "xh",
"version": "1.0.0",
"description": "",
"main": "modular01.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"backbone": "^1.3.3",
"underscore": "^1.8.3"
}
npm install //如果有package.json 会自动下载dependencies 里面的插件
npm install backbone -S //加上-S,会保存到package.json里面
搭建一个web服务器。
建立一个http.js
var http = require('http');
var server = http.createServer(function(require,response){
console.log('got a require');
response.write('hi');
response.end();
});
server.listen(3000);
//cmd上面输入
node http.js
然后在浏览器里面输入 localhost:3000,就能看到hi
nodejs01--什么是nodejs,nodejs的基本使用的更多相关文章
- [nodejs] nodejs开发个人博客(一)准备工作
前言 nodejs是运行在服务端的js,基于google的v8引擎.个人博客系统包含对数据库的增删查改,功能齐备,并且业务逻辑比较简单,是很多后台程序员为了检测学习成果,最先拿来练手的小网站程序.我也 ...
- nodejs nodejs模块使用及简单的示例
nodejs模块使用及简单的示例 参考菜鸟教程网:http://www.runoob.com/ 一.fs模块的使用: 1.文件操作: 读文件: //读文件 var fs=require('fs'); ...
- nodejs nodejs的操作
nodejs的操作 由于版本造成的命令不能正常安装,请参考五问题 一.概念: 参考百度百科: http://baike.baidu.com/link?url=aUrGlI8Sf20M_YGk8mh-- ...
- 第2章 安装Nodejs Nodejs基础 课程介绍
因为你做任何Nodejs应用,底层无非都是通过调用这些既有的开放的接口,来完成相应的功能.这个要注意,不同版本的Nodejs,接口不一定相同.甚至是相同的接口,使用规范也有区别.我们以这个版本来过这些 ...
- [nodejs] nodejs开发个人博客(七)后台登陆
定义后台路径 访问这个路径进入后台页面 http://localhost:8888/admin/login 在后台路由控制器里面(/admin/index.js)调用登陆控制器(/admin/logi ...
- [nodejs] nodejs开发个人博客(六)数据分页
控制器路由定义 首页路由:http://localhost:8888/ 首页分页路由:http://localhost:8888/index/2 /** * 首页控制器 */ var router=e ...
- [nodejs] nodejs开发个人博客(五)分配数据
使用回掉大坑进行取数据 能看明白的就看,看不明白的手动滑稽 /** * 首页控制器 */ var router=express.Router(); /*每页条数*/ var pageSize=5; r ...
- [nodejs] nodejs开发个人博客(四)数据模型
数据库模型 /model/db.js 数据库操作类,完成链接数据库和数据库的增删查改 查询表 /*查询*/ select:function(tableName,callback,where,field ...
- [nodejs] nodejs开发个人博客(三)载入页面
模板引擎 使用ejs作为我们博客的前端模板引擎,用来从json数据生成html字符串 安装:npm install ejs -save 使用:入口文件中写入下面代码,定义/view/目录为视图目录 / ...
- [nodejs] nodejs开发个人博客(二)入口文件
错误处理中间件 定义错误处理中间件必须使用4个参数,否则会被作为普通中间件 /*错误处理器*/ application.use(function(err,req,res,next){ console. ...
随机推荐
- 手把手教你从基础学习JQuery
JQuery JQuery 语法 1.jQuery("选择器").action();通过选择器调用事件函数 但jQuery中,jQuery可以用$代替,即$("选择器&q ...
- SCI论文写作中的注意事项
SCI论文一般都是英文的格式,其中有很多原则和细节需要我们注意,在我完成第一篇SCI论文的过程中,做些记录,同时和大家分享一下这些经验.同时也稍微改变一下园子里的人口比例,都是攻城狮,程序猿什么的也过 ...
- JAVA优雅停机的实现
最近在项目中需要写一个数据转换引擎服务,每过5分钟同步一次数据.具体实现是启动engine server后会初始化一个ScheduledExecutorService和一个ThreadPoolExec ...
- 获取Java VM中当前运行的所有线程
/** * 获取Java VM中当前运行的所有线程 * @return */ public static Thread[] findAllThreads() { ThreadGroup group = ...
- Array和ArrayList的区别与联系
博主今天去了一个java的实习面试,发现有好多java最基础的数据结构对于博主来说反而感到陌生,在面试官问一些常见的例如HashMap这样的数据结构,博主能回答的头头是道,但是在问到Array和Arr ...
- Swift 路由机制设计
设计模式 APP设计模式多种多样,从最初的MVC到MVVM,再到MVP,VIPER等.越来越多的设计模式被开发出来并得以应用,但不论我们用到哪种设计模式,只需要记住高内聚.低耦合那边是好的设计模式.在 ...
- Android如何实现定位获取
一:GPS定位: (1).要实用Adnroid平台的GPS设备,首先需要添加上权限,所以需要添加如下权限: uses-permission android:name= android.permissi ...
- 详细介绍Java虚拟机(JVM)
1. JVM生命周期 启动.启动一个Java程序时,一个JVM实例就产生了,任何一个拥有public static void main(String[] args)函数的class都可以作为JVM实例 ...
- VB6之摄像头控制
参考文献:http://www.cnblogs.com/xidongs/archive////.html 直接上代码: 'code by lichmama from cnblogs.com '@vb6 ...
- Scrapy 爬虫实例教程(一)---简介及资源列表
Scrapy(官网 http://scrapy.org/)是一款功能强大的,用户可定制的网络爬虫软件包.其官方描述称:" Scrapy is a fast high-level screen ...