gulp-load-pluginsというプラグインを使えば、他のプラグインを読み込む際にいちいちrequireを書き足さなくても使えるようになるようで、便利そうなので使ってみたいと思っています。
しかし、実際に使用しようとしても、gulp実行の際にエラーになって終了してしまいます。
gulp-load-plugins使用前のgulpfileと、使用後のgulpfileは以下のとおりです。
lang
1# gulp-load-plugins使用前 2gulp = require('gulp') 3plumber = require('gulp-plumber') 4jade = require('gulp-jade') 5 6gulp.task 'jade', -> 7 gulp.src('**/*.jade') 8 .pipe plumber() 9 .pipe jade 10 pretty: true 11 .pipe gulp.dest('./') 12gulp.task 'default', -> 13 gulp.watch '**/*.jade', ['jade']
lang
1# gulp-load-plugins使用後 2gulp = require('gulp') 3plugins = require('gulp-load-plugins')() 4 5gulp.task 'jade', -> 6 gulp.src('**/*.jade') 7 .pipe plugins.plumber() 8 .pipe plugins.jade 9 pretty: true 10 .pipe gulp.dest('./') 11gulp.task 'default', -> 12 gulp.watch '**/*.jade', ['jade']
gulp実行時のエラーメッセージは以下のとおりです。
lang
1C:\hogehoge\node_modules\gulp-load-plugins\index.js:47 2 throw new Error('Could not find dependencies. Do you have a package.json f 3 ^ 4Error: Could not find dependencies. Do you have a package.json file in your project? 5 at module.exports (C:\hogehoge\node_modules\gulp-load-plugins\index.js:47:11) 6 at Object.<anonymous> (C:\hogehoge\gulpfile.js:5:39) 7 at Module._compile (module.js:460:26) 8 at Object.Module._extensions..js (module.js:478:10) 9 at Module.load (module.js:355:32) 10 at Function.Module._load (module.js:310:12) 11 at Module.require (module.js:365:17) 12 at require (module.js:384:17) 13 at Liftoff.handleArguments (C:\Users\fugafuga\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:116:3) 14 at Liftoff.<anonymous> (C:\Users\fugafuga\AppData\Roaming\npm\node_modules\gulp\node_modules\liftoff\index.js:192:16)
plugins = require('gulp-load-plugins')()
この一行が存在しているだけで、この下に何があろうと上記のエラーメッセージが発生してしまうことを確認しました。
gulp-load-pluginsをインストールし忘れているということはありません。
どうすればgulp-load-pluginsを使用することができるのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。