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. ...
随机推荐
- Tomcat7的热部署
所谓热部署就是在tomcat不停机的情况下,将新的war包放上去,达到服务不中断,用户无察觉的目的,实现的原理很简单,这里做下记录,以便后期查看. 1.1 安装tomcat7 略 1.2 在tomca ...
- 【JavaScript学习】-JS内置对象2-Data对象
Date对象: Data对象可以储存任意一个日期,并且可以精确到毫秒数(1/1000 秒). 定义: //默认初始值定义: var dataName=new Date(); /*使用关键字new;Da ...
- nginx+ftp搭建图片服务器(Windows Server服务器环境下)
几种图片服务器的对比 1.直接使用ftp服务器,访问图片路径为 ftp://账户:密码@192.168.0.106/31275-105.jpg 不采用这种方式,不安全容易暴露ftp账户信息 2.直接使 ...
- php防止浏览器点击返回按钮重复提交数据
<!--html中存放隐藏域数据--> <input type="hidden" value='{$sun_nums}' name='sub_nums' /> ...
- GC机制总结
一.为什么需要GC 应用程序对资源操作,通常简单分为以下几个步骤: 1.为对应的资源分配内存 2.初始化内存 3.使用资源 4.清理资源 5.释放内存 应用程序对资源(内存使用)管理的方式,常见的一般 ...
- [编织消息框架][netty源码分析]11 UnpooledHeapByteBuf 与 ByteBufAllocator
每种ByteBuf都有相应的分配器ByteBufAllocator,类似工厂模式.我们先学习UnpooledHeapByteBuf与其对应的分配器UnpooledByteBufAllocator 如何 ...
- Kotlin入门第四课:简单工厂模式
Kotlin基础知识的学习,请参考之前的文章: Kotlin入门第一课:从对比Java开始 Kotlin入门第二课:集合操作 Kotlin入门第三课:数据类型 初次尝试用Kotlin实现Android ...
- 详解ASP.NET MVC 控制器
1 概述 在阅读本篇博文时,建议结合上篇博文:详解ASP.NET MVC 路由 一起阅读,效果可能会更好些. Controller(控制器)在ASP.NET MVC中负责控制所有客户端与服务端的 ...
- Ext ApplicationController&ref的使用
Ext ApplicationController&ref的使用 Ext.define('app.controller.ApplicationController', { //继承 Ext.a ...
- Linux下安装openvpn
工作上常常要通过vpn访问内网环境,最近一直在linux上搞东西,为了方便起见在linux上也安装了openvpn. 本次安装的openvpn不是把它当做服务端,而仅仅是以客户端来使用,所以没有那些服 ...