<?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>LETTUCE-EATER &#187; Node.js</title>
	<atom:link href="http://lettuce-eater.com/blog/archives/tag/node-js/feed" rel="self" type="application/rss+xml" />
	<link>http://lettuce-eater.com/blog</link>
	<description>レタス好きWEBデザイナーのログ</description>
	<lastBuildDate>Wed, 14 Sep 2016 10:54:24 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.41</generator>
	<item>
		<title>既存の gulp 環境データをローカルで動かすまでのログ</title>
		<link>http://lettuce-eater.com/blog/archives/351</link>
		<comments>http://lettuce-eater.com/blog/archives/351#comments</comments>
		<pubDate>Fri, 17 Jun 2016 01:53:43 +0000</pubDate>
		<dc:creator><![CDATA[moroto]]></dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[gulp]]></category>
		<category><![CDATA[Node.js]]></category>

		<guid isPermaLink="false">http://lettuce-eater.com/blog/?p=351</guid>
		<description><![CDATA[業務でgulp.jsを使うことになり、既存のデータを提供された後に環境を用意するまでに起こったことなどのメモです。環境はMac OS X El Capitanです。 参考：Gulp.js入門 – コー...]]></description>
				<content:encoded><![CDATA[<figure><img src="http://lettuce-eater.com/blog/wp-content/uploads/2016/06/201606gulpfirst.jpg" alt="201606gulpfirst" width="1280" height="512" class="aligncenter size-full wp-image-352" /></figure>
<div class="lead">業務でgulp.jsを使うことになり、既存のデータを提供された後に環境を用意するまでに起こったことなどのメモです。環境はMac OS X El Capitanです。</div>
<p><span id="more-351"></span></p>
<ul class="reference">
<li><span>参考：</span><a href="http://liginc.co.jp/web/tutorial/117900" title="Gulp.js入門 – コーディングを10倍速くする環境を作る方法まとめ" target="_blank">Gulp.js入門 – コーディングを10倍速くする環境を作る方法まとめ</a></li>
<li><span>参考：</span><a href="http://blog.mismithportfolio.com/web/20150822gulp-intro" title="【gulp】初めてでもできるgulpの導入ととりあえず使ってみるまで" target="_blank">【gulp】初めてでもできるgulpの導入ととりあえず使ってみるまで</a></li>
</ul>
<p>とりあえず必要な <a href="https://nodejs.org/en/" target="_blank">node.js</a> 導入後、ターミナルにて</p>
<pre class="brush: plain; title: ; notranslate">
$ node -v
</pre>
<p>でバージョン確認できたら完了</p>
<h2>gulpをグローバルインストール</h2>
<p>node.jsがインストールされていたら npm コマンドが使えるので、<br />
従来は下記のように入力しインストールするが若干変わったらしく・・・</p>
<pre class="brush: plain; title: ; notranslate">
$ npm install -g gulp
</pre>
<p>以下でインストールする。</p>
<pre class="brush: plain; title: ; notranslate">
$ npm install --global gulp-cli
</pre>
<p>※ちなみにgulp導入済みだった場合は、衝突を防ぐため下記を実行で一旦gulpを削除してからインストールをした方が良いようです</p>
<pre class="brush: plain; title: ; notranslate">
$ npm rm --global gulp
</pre>
<p>最後に下記コマンドでバージョンが表示されれば、各プロジェクトにgulpをインストールする準備完了</p>
<pre class="brush: plain; title: ; notranslate">
$ gulp -v
</pre>
<h2>作業ディレクトリごとにgulpをローカルインストール</h2>
<p>まず npm で cd コマンドを使い作業環境に移動するのですが、作業ディレクトリをターミナルアイコンにドラッグして起動すると移動済み状態で開始するというのを知ってからは後者の方法で進めています。</p>
<p>下記コマンドで npm セッティング。設定内容はとりあえず全部 Yes ということで -y をつけると自動で進むらしい。</p>
<pre class="brush: plain; title: ; notranslate">
$ npm init -y
</pre>
<p>package.json が作成されるので、ようやく gulp のローカルインストールへ。<br />
下記コマンドで現在の作業ディレクトリに gulp 関係のファイルがインストールされます。</p>
<pre class="brush: plain; title: ; notranslate">
$ npm install gulp --save-dev
</pre>
<p>インストール後、gulpfile.js というのを作りいろいろ記述していくようなのですが、今回は既存環境の実行だったのですでに存在していました。</p>
<h2>gulpを走らせる</h2>
<p>既存の gulpfile.js ということで、下記コマンドを実行すれば良いはずだったんですが</p>
<pre class="brush: plain; title: ; notranslate">
$ gulp
</pre>
<p>すぐにプラグイン不足ということに気づき、gulpfile.js に記載されているプラグインをインストールしていきます。<br />
プラグインのインストールコマンド</p>
<pre class="brush: plain; title: ; notranslate">
$ npm install プラグイン名 --save-dev
</pre>
<p>プラグインのアンインストールコマンド</p>
<pre class="brush: plain; title: ; notranslate">
$ npm uninstall プラグイン名 --save-dev
</pre>
<p>下記記述方法で一括インストール可能</p>
<pre class="brush: plain; title: ; notranslate">
$ npm install --save-dev プラグイン名 プラグイン名 ...
</pre>
<p>ただ、どうしても imagemin-pngquant というプラグインが下記エラーでインストールできず</p>
<pre class="brush: plain; title: ; notranslate">
npm ERR! pngquant-bin@3.1.0 postinstall: `node lib/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the pngquant-bin@3.1.0 postinstall script.
npm ERR! This is most likely a problem with the pngquant-bin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node lib/install.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls pngquant-bin
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 15.4.0
npm ERR! command &quot;node&quot; &quot;/usr/local/bin/npm&quot; &quot;install&quot; &quot;imagemin-pngquant&quot; &quot;--save-dev&quot;
npm ERR! cwd /Users/XXXX/XXXX/XXXX/XXXX
npm ERR! node -v v0.11.11
npm ERR! npm -v 1.3.25
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/XXXX/XXXX/XXXX/XXXX/npm-debug.log
npm ERR! not ok code 0
</pre>
<p>よくよく読んでいるとnodeとかnpmが古いんじゃないかと思い下記サイト様を参考にアップデートしました。</p>
<ul class="reference">
<li><span>参考：</span><a href="http://blog.nocorica.jp/2015/03/nodejs-npm-update/" title="Node.js と npm のアップデート" target="_blank">Node.js と npm のアップデート</a></li>
</ul>
<p>imagemin-pngquant のインストールが完了し、再び下記コマンドで無事にgulp環境が動いて終了です。</p>
<pre class="brush: plain; title: ; notranslate">
$ gulp
</pre>
<p>今回の教訓はエラーちゃんと読め！でした。</p>
]]></content:encoded>
			<wfw:commentRss>http://lettuce-eater.com/blog/archives/351/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
