現在下記サイトを参考にGulp、Sassの学習を行なっております。
Gulp で SCSS のコンパイルから bourbon の導入までを試す - Gulp で作る Web フロントエンド開発環境 #1
json
1// package.json 2{ 3 "name": "psyence_media", 4 "version": "1.0.0", 5 "description": "", 6 "main": "index.js", 7 "scripts": { 8 "test": "echo \"Error: no test specified\" && exit 1" 9 }, 10 "author": "", 11 "license": "ISC", 12 "devDependencies": { 13 "coffee-script": "^1.12.7", 14 "gulp": "^3.9.1", 15 "gulp-sass": "^3.1.0" 16 } 17} 18
gulpダウンロードもうまくいっているはずなのですが、gulp scss
やgulp -v
などとやってもzsh: command not found: gulp
と返されてしまいます。
ディレクトリ配下キャプチャ
PATHが通っているかの確認
検索しているとPATHが通っていない問題の可能性ともあったので.bash_profile
、.bashrc
両方にそれらしきPATHも追加してみました。
bash
1# =========== .bashrc =========== 2git_branch(){ 3 echo $(git branch --no-color 2>/dev/null | sed -ne "s/^* (.*)$/\1/p") 4} 5PS1='[\033[36m]\w[\033[0m]:[\033[35m]$(git_branch)[\033[0m]$' 6 7#macportsの設定 8export path=/opt/local/bin:/opt/local/sbin:$path 9export manpath=/opt/local/man:$manpath 10export PATH=/Users/ユーザー名/npm/bin:$PATH # 追加 11 12# =========== .bash_profile =========== 13if [ "$TERM_PROGRAM" = "Apple_Terminal" ]; then 14 15 if [ -f ~/.bashrc ]; then 16 source ~/.bashrc 17 fi 18fi 19 20if [-f ~/.bashrc]; 21 then source ~/.bashrc 22fi 23 24#VScode PATHの設定 25code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;} 26 27export PATH="/opt/local/bin:/opt/local/sbin:$PATH" 28export PATH=/Users/ユーザー名/npm/bin:$PATH # 追加
他に考えられる原因がありましたら教えていただけますと助かります。
よろしくお願いいたします。
質問追記 1/9
json
1$ ls node_modules/.bin | grep gulp 2gulp // <- 追加されてる事を確認 3 4$ npm bin 5/Users/ユーザー名/Google ドライブ/MyPractice/Gulp/PSYENCE_MEDIA/node_modules/.bin 6 7$ npm install -D gulp 8gulpインストール後、下記キャプチャのようになる 9 10$ npm run gulp --version 115.4.2 12 13$ npm run gulp --tasks 14npm ERR! missing script: gulp 15 16npm ERR! A complete log of this run can be found in: 17npm ERR!
npm bin
をはじめにすればgulpのグローバルインストールの必要がなくなるという解釈で大丈夫でしょうか?- 手順の通りに進めたつもりではいるのですが、以前としてnot foundのままです。
- "scripts": { ... }はインストールするとpackage.jsonに自動的に記述するのでしょうか?それとも自身でベタ書きでしょうか?
まだまだ理解不足の中での質問で恐縮ですがよろしくお願いします。
質問追記 1/10
npm run gulp
のところでエラーを吐かれてしまいます。
この場合どこを修正すればよろしいでしょうか?
sh
1# バージョン確認 → npm run gulpの実行結果です 2 3[PSYENCE_MEDIA] npm run gulp --version 13:21:09 45.4.2 5[PSYENCE_MEDIA] npm run gulp 13:19:29 6 7> psyence_media@1.0.0 gulp /Users/ユーザー名/Google ドライブ/MyPractice/Gulp/PSYENCE_MEDIA 8> gulp 9 10[13:20:58] Failed to load external module coffeescript/register 11[13:20:58] Requiring external module coffee-script/register 12[13:20:58] Using gulpfile ~/Google ドライブ/MyPractice/Gulp/PSYENCE_MEDIA/gulpfile.coffee 13[13:20:58] Task 'default' is not in your gulpfile 14[13:20:58] Please check the documentation for proper gulpfile formatting 15npm ERR! code ELIFECYCLE 16npm ERR! errno 1 17npm ERR! psyence_media@1.0.0 gulp: `gulp` 18npm ERR! Exit status 1 19npm ERR! 20npm ERR! Failed at the psyence_media@1.0.0 gulp script. 21npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 22 23npm ERR! A complete log of this run can be found in: 24npm ERR! /Users/ユーザー名/.npm/_logs/2018-01-10T04_20_58_200Z-debug.log 25[PSYENCE_MEDIA]
上記エラーキャプチャ
質問追記 1/13
ご返事が遅くなり申し訳ありません。
メモも兼ねて記載させてください。
json
1#gulpfile.coffee 2gulp = require 'gulp' 3sass = require 'gulp-sass' 4 5gulp.task 'scss', -> 6 gulp.src './src/scss/**/*.scss' 7 .pipe sass() 8 .pipe gulp.dest('./dest/assets/css') 9
エラー文、Task 'default' is not in your gulpfile、defaultで設定されているものがないためエラーということでしょうか。
その場合だと、今回はgulpfile.coffeeファイルに対してgulp.task 'scss'タスクを設定しています。
今回の場合だとgulp scssで実行するはずだと思いましたがzsh: command not found: gulpとなります。
となるとやはりPATHの問題だと思うのですが、含まれていれば安心というアドバイスなので、npmのPATHを追加するやり方について調べようと思います。
bash
1 2$ npm bin -g 3/usr/local/bin 4 5$ echo $PATH 6/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin 7
質問追記 1/23
json
1{ 2 "name": "psyence_media", 3 "version": "1.0.0", 4 "description": "", 5 "main": "index.js", 6 "scripts": { 7 "test": "echo \"Error: no test specified\" && exit 1", 8 "gulp": "gulp" # ご指摘いただいた追加の箇所 9 }, 10 "author": "", 11 "license": "ISC", 12 "devDependencies": { 13 "coffee-script": "^1.12.7", 14 "gulp": "^3.9.1", 15 "gulp-sass": "^3.1.0" 16 } 17}

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/01/09 06:23
2018/01/09 09:09
2018/01/09 09:12
2018/01/09 09:16
2018/01/10 04:36
2018/01/10 05:29