<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title> &#187; nodejs</title>
	<atom:link href="http://www.liguosong.com/category/nodejs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.liguosong.com</link>
	<description></description>
	<lastBuildDate>Tue, 08 May 2018 01:02:19 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.2</generator>
		<item>
		<title>bower简明入门教程</title>
		<link>http://www.liguosong.com/2017/11/24/bower%e7%ae%80%e6%98%8e%e5%85%a5%e9%97%a8%e6%95%99%e7%a8%8b/</link>
		<comments>http://www.liguosong.com/2017/11/24/bower%e7%ae%80%e6%98%8e%e5%85%a5%e9%97%a8%e6%95%99%e7%a8%8b/#comments</comments>
		<pubDate>Fri, 24 Nov 2017 02:23:49 +0000</pubDate>
		<dc:creator>lgs</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[nodejs]]></category>

		<guid isPermaLink="false">http://www.liguosong.com/?p=639</guid>
		<description><![CDATA[什么是bower Bower是twitter 推出的一款包管理工具，它可用于搜索、安装和卸载如JavaScri [...]]]></description>
				<content:encoded><![CDATA[<p><strong>什么是bower</strong></p>
<p>Bower是twitter 推出的一款包管理工具，它可用于搜索、安装和卸载如JavaScript、HTML、CSS之类的网络资源。</p>
<p><strong>MAC安装bower</strong></p>
<pre class="brush:other">brew install bower</pre>
<p>PS：brew安装会自行安装bower需要的依赖环境，如果本机安装了node和git环境，也可以通过下面的命令安装</p>
<pre class="brush:other">npm install -g bower</pre>
<p>安装完之后输入如下命令</p>
<pre class="brush:other">bower -help</pre>
<p>会出现如下的截图<a href="http://www.liguosong.com/wp-content/uploads/2017/11/WechatIMG61.jpeg"><img class="alignnone size-full wp-image-644" alt="WechatIMG61" src="http://www.liguosong.com/wp-content/uploads/2017/11/WechatIMG61.jpeg" width="1262" height="1272" /></a></p>
<p><strong>bower初始化</strong></p>
<p>先看一下我本机的目录</p>
<p><a href="http://www.liguosong.com/wp-content/uploads/2017/11/WechatIMG62.jpeg"><img class="alignnone size-full wp-image-646" alt="WechatIMG62" src="http://www.liguosong.com/wp-content/uploads/2017/11/WechatIMG62.jpeg" width="988" height="132" /></a></p>
<p>在bower目录下创建.bowerrc文件，并在文件中添加如下内容</p>
<pre class="brush:other">{
	"directory" : "bower_extensions"
}</pre>
<p>然后执行初始化命令</p>
<pre class="brush:other">bower init</pre>
<p>然后根据提示输入对应的内容~~最后会生成bower.json文件，里面保存的就是刚才输入的信息。<a href="http://www.liguosong.com/wp-content/uploads/2017/11/WechatIMG63.jpeg"><img class="alignnone size-full wp-image-649" alt="WechatIMG63" src="http://www.liguosong.com/wp-content/uploads/2017/11/WechatIMG63.jpeg" width="1882" height="1100" /></a></p>
<p><strong>包的安装</strong></p>
<p>下面我们来安装第一个js包，输入如下命令：</p>
<pre class="brush:other">bower install jquery</pre>
<p>这时候就会在刚才设置的目录中保存了jquery的文件~~ 注意下面的命令，会在bower.json文件中dependencies的节点保存一行刚才安装的jquery信息</p>
<pre class="brush:other">bower install jquery --save</pre>
<p>当然也可以通过下面的方式安装</p>
<pre class="brush:other"># installs the project dependencies listed in bower.json
$ bower install
# registered package
$ bower install jquery
# GitHub shorthand
$ bower install desandro/masonry
# Git endpoint
$ bower install git://github.com/user/package.git
# URL
$ bower install http://example.com/script.js</pre>
<p><strong> </strong><strong>包的更新</strong></p>
<p>上面安装的是最新版的高版本jquery，假如想要兼容低版本浏览器的呢？<br />
已经查到兼容低版本浏览器的jquery版本为1.11.3，下面直接修改bower.json文件中的jquery版本号如下：</p>
<pre class="brush:other">  "dependencies": {
    "jquery": "~1.11.3"
  }</pre>
<p>然后执行如下命令</p>
<pre class="brush:other">bower update</pre>
<p>这时候，刚才下载的jquery就已经换成1.11.3的版本了~~</p>
<p><strong>其它命令</strong></p>
<pre class="brush:other">bower info jquery   包的信息查看
bower search bootstrap  包的查找
bower uninstall jquery   包的删除
bower home 打开在bower.json中设置的homepage</pre>
<p>更多详细的命令，请访问官方文档~~https://bower.io/docs/api/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liguosong.com/2017/11/24/bower%e7%ae%80%e6%98%8e%e5%85%a5%e9%97%a8%e6%95%99%e7%a8%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>golang,java,python,nodejs,php计算斐波那契数列速度对比</title>
		<link>http://www.liguosong.com/2013/07/27/golangjavapythonnodejsphp%e8%ae%a1%e7%ae%97%e6%96%90%e6%b3%a2%e9%82%a3%e5%a5%91%e6%95%b0%e5%88%97%e9%80%9f%e5%ba%a6%e5%af%b9%e6%af%94/</link>
		<comments>http://www.liguosong.com/2013/07/27/golangjavapythonnodejsphp%e8%ae%a1%e7%ae%97%e6%96%90%e6%b3%a2%e9%82%a3%e5%a5%91%e6%95%b0%e5%88%97%e9%80%9f%e5%ba%a6%e5%af%b9%e6%af%94/#comments</comments>
		<pubDate>Sat, 27 Jul 2013 13:19:25 +0000</pubDate>
		<dc:creator>lgs</dc:creator>
				<category><![CDATA[golang]]></category>
		<category><![CDATA[nodejs]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.liguosong.com/?p=178</guid>
		<description><![CDATA[同样的程序，这五种语言速度对比。java速度最快，其次golang，nodejs，python，php。在这里 [...]]]></description>
				<content:encoded><![CDATA[<p>同样的程序，这五种语言速度对比。java速度最快，其次golang，nodejs，python，php。在这里php，python已经与前面的语言不在同一个级别了。据说python可以在速度上优化一下，但我现在还处于对python了解阶段。并没有过多的深入研究。<span id="more-178"></span>不说了，上图：</p>
<p><a href="http://www.liguosong.com/wp-content/uploads/2013/07/fibNumber-test副本.jpg"><img class="alignnone size-full wp-image-182" alt="fibNumber-test副本" src="http://www.liguosong.com/wp-content/uploads/2013/07/fibNumber-test副本.jpg" width="640" height="514" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.liguosong.com/2013/07/27/golangjavapythonnodejsphp%e8%ae%a1%e7%ae%97%e6%96%90%e6%b3%a2%e9%82%a3%e5%a5%91%e6%95%b0%e5%88%97%e9%80%9f%e5%ba%a6%e5%af%b9%e6%af%94/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nodejs os包一些函数介绍</title>
		<link>http://www.liguosong.com/2013/07/07/nodejs-os%e5%8c%85%e4%b8%80%e4%ba%9b%e5%87%bd%e6%95%b0%e4%bb%8b%e7%bb%8d/</link>
		<comments>http://www.liguosong.com/2013/07/07/nodejs-os%e5%8c%85%e4%b8%80%e4%ba%9b%e5%87%bd%e6%95%b0%e4%bb%8b%e7%bb%8d/#comments</comments>
		<pubDate>Sun, 07 Jul 2013 06:34:46 +0000</pubDate>
		<dc:creator>lgs</dc:creator>
				<category><![CDATA[nodejs]]></category>

		<guid isPermaLink="false">http://www.liguosong.com/?p=49</guid>
		<description><![CDATA[使用的时候需要先包含包 var os = require(&#8216;os&#8217;); os.host [...]]]></description>
				<content:encoded><![CDATA[<p>使用的时候需要先包含包</p>
<p>var os = require(&#8216;os&#8217;);</p>
<p>os.hostname();    返回用户电脑的名称。<span id="more-49"></span></p>
<p>os.type()         返回用户的系统：如linux</p>
<p>os.platform() 返回系统的平台：如linux</p>
<p>os.arch()      CPU位数 如x86</p>
<p>os.release()  系统版本</p>
<p>os.uptime()   返回系统正常运行时间，以秒为单位。</p>
<p>os.totalmem()  系统全部内存</p>
<p>os.freemem() 系统空闲内存</p>
<p>os.cpus()   CPU相关参数</p>
<p>os.networkInterfaces()    网络连接的参数，如ip地址</p>
<p>os.loadavg()   系统在过去的1分钟、5分钟和15分钟内的平均负载</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liguosong.com/2013/07/07/nodejs-os%e5%8c%85%e4%b8%80%e4%ba%9b%e5%87%bd%e6%95%b0%e4%bb%8b%e7%bb%8d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nodejs上传图片</title>
		<link>http://www.liguosong.com/2013/07/07/32/</link>
		<comments>http://www.liguosong.com/2013/07/07/32/#comments</comments>
		<pubDate>Sun, 07 Jul 2013 02:59:35 +0000</pubDate>
		<dc:creator>lgs</dc:creator>
				<category><![CDATA[nodejs]]></category>

		<guid isPermaLink="false">http://www.liguosong.com/?p=32</guid>
		<description><![CDATA[方法一： exports.upload = function(req, res){ //引入必要的包 var  [...]]]></description>
				<content:encoded><![CDATA[<p>方法一：</p>
<pre class="brush:javascript">exports.upload = function(req, res){
    //引入必要的包
    var fs = require('fs');
    var path = require('path');

    //获取上传的文件名称，路径
    var fileName = req.files.image.filename;
    var tmp_path = req.files.image.path;
    var target_path = __dirname + "/upload/" + fileName;

    //判断文件是否存在
    path.exists(tmp_path, function(isExist){
        if (isExist){
            //在这部执行将tmp下的图片重名到指定的目录下
            fs.rename(tmp_path, target_path, function(err){
                if (err){
                    console.dir(err); //如果这里打印出错误，请查看target_path路径
                };
            });
        } else {
            console.log("No");
        }
    });

    console.dir(req.files);

    //Redirec index.
    res.redirect("/");
}</pre>
<p>方法二：</p>
<pre class="brush:javascript">exports.upload = function(req, res){
    var fs = require('fs');
    var path = require('path');
    var util = require('util');
    var fileName = req.files.image.filename;
    var tmp_path = req.files.image.path;
    var target_path = __dirname + "/upload/" + fileName;

    path.exists(tmp_path, function(isExist){
        if (isExist){
            ins = fs.createReadStream(tmp_path);
            ous = fs.createWriteStream(__dirname + "/upload/" + fileName);
            util.pump(ins, ous, function(err){
                console.dir(err);
                });
        } else {
            console.log("No");
        }
    });

    console.dir(req.files);
    //Redirec index.
    res.redirect("/");
}</pre>
<p>注意：方法一可以在使用完后，不用删除tmp下的图片，它会自动删除tmp下的文件。但是方法二，要手动删除tmp下的图片。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liguosong.com/2013/07/07/32/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
