jackfranklin / gulp-load-plugins

Automatically load in gulp plugins
https://github.com/jackfranklin/gulp-load-plugins
MIT License
757 stars 55 forks source link

Can't load gulp-modify-css-urls #89

Closed movie4 closed 9 years ago

movie4 commented 9 years ago

Thanks for amazing plugin!

Can't load https://github.com/dustinspecker/gulp-modify-css-urls

.pipe(plugins.modifyCssUrls({ }))
[17:35:20] Error: Cannot find module 'gulp-modify-css-urls' from '/Volumes/Work/ITCase/itcase-logos'
    at Function.module.exports [as sync] (/Volumes/Work/ITCase/itcase-logos/node_modules/resolve/lib/sync.js:33:11)
    at requireFn (/Volumes/Work/ITCase/itcase-logos/node_modules/gulp-load-plugins/index.js:42:25)
    at Object.defineProperty.get (/Volumes/Work/ITCase/itcase-logos/node_modules/gulp-load-plugins/index.js:65:18)
    at Gulp.<anonymous> (/Volumes/Work/ITCase/itcase-logos/gulp-tasks/css.js:72:20)
    at module.exports (/Volumes/Work/ITCase/itcase-logos/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/Volumes/Work/ITCase/itcase-logos/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Volumes/Work/ITCase/itcase-logos/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Volumes/Work/ITCase/itcase-logos/node_modules/orchestrator/index.js:134:8)
    at /Users/Arkasha/.nvm/versions/node/v4.0.0/lib/node_modules/gulp-cli/index.js:133:20
    at doNTCallback0 (node.js:407:9)

use npm --version 3.3.10

How fix it?

Thanks

jackfranklin commented 9 years ago

Is it available under another name? Can you log out Object.keys(plugins) to see what that is?

Have you configured the plugin differently to the defaults at all? It would be useful to see more of your Gulpfile.

movie4 commented 9 years ago

I use simple gulpfile for test it

'use strict';

var gulp = require('gulp'),
    plugins = require('gulp-load-plugins')({ pattern: ['gulp-*', 'gulp.*'] });

gulp.task('modifyUrls', function () {
  return gulp.src('./static/css/__main.css')
    .pipe(plugins.modifyCssUrls({
      modify: function (url, filePath) {
        return 'app/' + url;
      },
      prepend: 'https://fancycdn.com/',
      append: '?cache-buster'
    }))
    .pipe(gulp.dest('./'));
});
[18:34:22] Using gulpfile /Volumes/Work/ITCase/ee-shoes/gulpfile.js
[18:34:22] Starting 'modifyUrls'...
[18:34:22] 'modifyUrls' errored after 28 ms
[18:34:22] Error: Cannot find module 'gulp-modify-css-urls' from '/Volumes/Work/ITCase/ee-shoes'
    at Function.module.exports [as sync] (/Volumes/Work/ITCase/ee-shoes/node_modules/gulp-load-plugins/node_modules/resolve/lib/sync.js:33:11)
    at requireFn (/Volumes/Work/ITCase/ee-shoes/node_modules/gulp-load-plugins/index.js:42:25)
    at Object.defineProperty.get (/Volumes/Work/ITCase/ee-shoes/node_modules/gulp-load-plugins/index.js:65:18)
    at Gulp.<anonymous> (/Volumes/Work/ITCase/ee-shoes/gulpfile.js:11:18)
    at module.exports (/Volumes/Work/ITCase/ee-shoes/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/Volumes/Work/ITCase/ee-shoes/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Volumes/Work/ITCase/ee-shoes/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Volumes/Work/ITCase/ee-shoes/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at /Users/Arkasha/.nvm/versions/node/v4.2.2/lib/node_modules/gulp-cli/index.js:133:20
    at doNTCallback0 (node.js:419:9)

Is it available under another name?

thanks for quick reply!

jackfranklin commented 9 years ago

Can you console.log(Object.keys(plugins)) to see what's defined?

jackfranklin commented 9 years ago

And the plugin is definitely listed in your package.json file?

movie4 commented 9 years ago

package.json

  "devDependencies": {
    "gulp": "^3.9.0",
    "gulp-batch": "~1.0.5",
    "gulp-load-plugins": "^1.0.0",
    "gulp-modify-css-urls": "^0.2.1",
    "gulp-watch": "^4.3.5"
  },

console

   gulp modifyUrls
[ 'gulp-batch', 'gulp-modify-css-urls', 'gulp-watch' ]
[19:01:27] Using gulpfile /Volumes/Work/ITCase/ee-shoes/gulpfile.js
[19:01:27] Starting 'modifyUrls'...
[19:01:27] 'modifyUrls' errored after 7.77 ms
[19:01:27] Error: Cannot find module 'gulp-modify-css-urls' from '/Volumes/Work/ITCase/ee-shoes'
    at Function.module.exports [as sync] (/Volumes/Work/ITCase/ee-shoes/node_modules/gulp-load-plugins/node_modules/resolve/lib/sync.js:33:11)
    at requireFn (/Volumes/Work/ITCase/ee-shoes/node_modules/gulp-load-plugins/index.js:42:25)
    at Object.defineProperty.get (/Volumes/Work/ITCase/ee-shoes/node_modules/gulp-load-plugins/index.js:68:18)
    at Gulp.<anonymous> (/Volumes/Work/ITCase/ee-shoes/gulpfile.js:7:18)
    at module.exports (/Volumes/Work/ITCase/ee-shoes/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/Volumes/Work/ITCase/ee-shoes/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Volumes/Work/ITCase/ee-shoes/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Volumes/Work/ITCase/ee-shoes/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at /Users/Arkasha/.nvm/versions/node/v4.2.2/lib/node_modules/gulp-cli/index.js:133:20
    at doNTCallback0 (node.js:419:9)

iwith gulp-watch - work fine

   gulp watch
[18:58:54] Using gulpfile /Volumes/Work/ITCase/ee-shoes/gulpfile.js
[18:58:54] Starting 'watch'...
[18:58:54] Finished 'watch' after 105 ms
[18:58:57] __main.css was changed
watch work
[18:58:58] __main.css was changed
watch work
[18:58:59] __main.css was changed
watch work
[18:58:59] __main.css was changed
watch work

gulpfile with watch task

var gulp = require('gulp'),
    plugins = require('gulp-load-plugins')({ pattern: ['gulp-*', 'gulp.*'] });

gulp.task('modifyUrls', function () {
  return gulp.src('./static/css/__main.css')
    .pipe(plugins.modifyCssUrls({
      modify: function (url, filePath) {
        return 'app/' + url;
      },
      prepend: 'https://fancycdn.com/',
      append: '?cache-buster'
    }))
    .pipe(gulp.dest('./'));
});

gulp.task('watch', function() {

  plugins.watch('./static/css/__main.css', { verbose: true },
    plugins.batch(function (obj, cb) {
      console.log('watch work');
      cb();
  }));

});
jackfranklin commented 9 years ago
[ 'gulp-batch', 'gulp-modify-css-urls', 'gulp-watch' ]

You should be able to refer to the plugin as plugins['gulp-modify-css-urls'] but I'm not sure why it's not being renamed as we would expect...

callumacrae commented 9 years ago

Are plugins.batch and plugins.watch working?

movie4 commented 9 years ago

Are plugins.batch and plugins.watch working? - yes

shinnn commented 9 years ago
npm ls gulp-load-plugins
movie4 commented 9 years ago

think problem in `gulp-modify-css-urls.

gulp.task('test', function() {
  console.log(plugins.modifyUrls);
  console.log(plugins['gulp-modify-css-urls']);
});
[19:41:46] Starting 'test'...
undefined
undefined
[19:41:46] Finished 'test' after 649 μs
'use strict';

var gulp = require('gulp'),
    plugins = require('gulp-load-plugins')({ pattern: ['gulp-*', 'gulp.*'] });

var modifyCssUrls = require('gulp-modify-css-urls');

gulp.task('test', function() {
  console.log(modifyCssUrls);
});
   gulp test
module.js:339
    throw err;
    ^

Error: Cannot find module 'gulp-modify-css-urls'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Volumes/Work/ITCase/ee-shoes/gulpfile.js:6:21)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)

https://github.com/dustinspecker/gulp-modify-css-urls/issues/3

movie4 commented 9 years ago
   npm ls gulp-load-plugins
npm WARN unmet dependency /Volumes/Work/ITCase/ee-shoes/node_modules/browser-sync/node_modules/chokidar/node_modules/fsevents/node_modules/fstream-ignore requires fstream@'~0.1.17' but will load
npm WARN unmet dependency /Volumes/Work/ITCase/ee-shoes/node_modules/browser-sync/node_modules/chokidar/node_modules/fsevents/node_modules/fstream,
npm WARN unmet dependency which is version 1.0.8
npm WARN unmet dependency /Volumes/Work/ITCase/ee-shoes/node_modules/gulp-watch/node_modules/chokidar/node_modules/fsevents/node_modules/fstream-ignore requires fstream@'~0.1.17' but will load
npm WARN unmet dependency /Volumes/Work/ITCase/ee-shoes/node_modules/gulp-watch/node_modules/chokidar/node_modules/fsevents/node_modules/fstream,
npm WARN unmet dependency which is version 1.0.8
ee_shoes@0.0.2 /Volumes/Work/ITCase/ee-shoes
└── gulp-load-plugins@1.0.0 
shinnn commented 9 years ago

Ah, OK I found the root cause.

gulp-modify-css-urls's entry point is index.js but the npm package doesn't include index.js.

$ npm install gulp-modify-css-urls@0.2.1
$ ls node_modules/gulp-modify-css-urls
> LICENSE       README.md     lib/          package.json

@jackfranklin This is not a gulp-load-plugins issue.

dustinspecker commented 9 years ago

Yep, this was my fault. Sorry about this guys. I changed the structure last night and forgot to update package.json.

jackfranklin commented 9 years ago

@dustinspecker no worries!

movie4 commented 9 years ago

Thanks for help!