Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lodash error while generating icons #18

Closed
lmartins opened this issue May 31, 2014 · 32 comments
Closed

Lodash error while generating icons #18

lmartins opened this issue May 31, 2014 · 32 comments

Comments

@lmartins
Copy link

Any idea what might be causing this?

/Users/luismartins/Sites/prestashop/themes/domatica/src/node_modules/gulp-iconfont-css/index.js:104
                        throw error;
                              ^
TypeError: Object function lodash(value) {
      // don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
      return (value && typeof value == 'object' && !isArray(value) && hasOwnProperty.call(value, '__wrapped__'))
       ? value
       : new lodashWrapper(value);
    } has no method 'template'
  at Function.exports.lodash.render (/Users/luismartins/Sites/prestashop/themes/domatica/src/node_modules/gulp-iconfont-css/node_modules/consolidate/lib/consolidate.js:537:56)
  at /Users/luismartins/Sites/prestashop/themes/domatica/src/node_modules/gulp-iconfont-css/node_modules/consolidate/lib/consolidate.js:146:25
  at /Users/luismartins/Sites/prestashop/themes/domatica/src/node_modules/gulp-iconfont-css/node_modules/consolidate/lib/consolidate.js:99:5
  at fs.js:266:14
  at /Users/luismartins/Sites/prestashop/themes/domatica/src/node_modules/gulp-watch/node_modules/vinyl-fs/node_modules/graceful-fs/graceful-fs.js:104:5
  at /Users/luismartins/Sites/prestashop/themes/domatica/src/node_modules/gulp/node_modules/vinyl-fs/node_modules/graceful-fs/graceful-fs.js:104:5
  at Object.oncomplete (fs.js:107:15)
@lmartins
Copy link
Author

lmartins commented Jun 4, 2014

Sorry to insist but anyone having this issue?
No mater what I do I get this error, even without passing any configuration option besides the fontName.

@lmartins
Copy link
Author

lmartins commented Jun 4, 2014

Btw, I've manually installed an old version of this plugin (0.0.5) and it compiles without any issue. As soon as I upgrade to latest version something breaks.

@backflip
Copy link
Owner

Hey Luis, I'm sorry about the delay.
Could you upload your gulpfile.js and package.json somewhere so I can try to reproduce it?

@lmartins
Copy link
Author

Hey Thomas,

You can find them here:
https://gist.github.com/lmartins/7e1cea984b3f80294ac8

Just tried with the latest versions and still throws the same error.

Tks.

@backflip
Copy link
Owner

Works fine for me if I use it with one of the provided templates.
Could you post your custom scss template, too?

@lmartins
Copy link
Author

I've updated the gist with the template file, but is exactly what you have in the repo. I've copied again just to be sure.

Even when I don't pass the path option I get the same error.

@backflip
Copy link
Owner

Hm, weird. Which versions of node and npm do you have?
Anyway, does it work when you use the setup in #9 (comment) instead of the plugin?

@lmartins
Copy link
Author

Im running node v0.10.6 and npm 1.4.10

Tried the approach you mention and first I got:

/Users/luismartins/Sites/idomlive.com/.src/gulpfile.js:209
      codepoints = _.map(codepoints, function(codepoint) {
                   ^
ReferenceError: _ is not defined
    at Duplexer.<anonymous> (/Users/luismartins/Sites/idomlive.com/.src/gulpfile.js:209:20)
    at Duplexer.EventEmitter.emit (events.js:98:17)
    at Transform.<anonymous> (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-iconfont/src/index.js:23:12)
    at Transform.EventEmitter.emit (events.js:95:17)
    at Transform.endStream [as _flush] (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-iconfont/node_modules/gulp-svgicons2svgfont/src/index.js:117:12)
    at Transform.<anonymous> (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-iconfont/node_modules/gulp-svgicons2svgfont/node_modules/readable-stream/lib/_stream_transform.js:135:12)
    at Transform.g (events.js:180:16)
    at Transform.EventEmitter.emit (events.js:117:20)
    at finishMaybe (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-iconfont/node_modules/gulp-svgicons2svgfont/node_modules/readable-stream/lib/_stream_writable.js:372:12)
    at endWritable (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-iconfont/node_modules/gulp-svgicons2svgfont/node_modules/readable-stream/lib/_stream_writable.js:379:3)

Tried requiring lodash in the gulp file but then it returns:

/Users/luismartins/Sites/idomlive.com/.src/gulpfile.js:218
        .pipe(plugins.consolidate('lodash', {
                      ^
TypeError: Object #<Object> has no method 'consolidate'
    at Duplexer.<anonymous> (/Users/luismartins/Sites/idomlive.com/.src/gulpfile.js:218:23)
    at Duplexer.EventEmitter.emit (events.js:98:17)
    at Transform.<anonymous> (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-iconfont/src/index.js:23:12)
    at Transform.EventEmitter.emit (events.js:95:17)
    at Transform.endStream [as _flush] (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-iconfont/node_modules/gulp-svgicons2svgfont/src/index.js:117:12)
    at Transform.<anonymous> (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-iconfont/node_modules/gulp-svgicons2svgfont/node_modules/readable-stream/lib/_stream_transform.js:135:12)
    at Transform.g (events.js:180:16)
    at Transform.EventEmitter.emit (events.js:117:20)
    at finishMaybe (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-iconfont/node_modules/gulp-svgicons2svgfont/node_modules/readable-stream/lib/_stream_writable.js:372:12)
    at endWritable (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-iconfont/node_modules/gulp-svgicons2svgfont/node_modules/readable-stream/lib/_stream_writable.js:379:3)

@backflip
Copy link
Owner

I would suggest updating to 0.10.29. nvm comes in really handy when you want multiple versions running in parallel.

In above example, you would need to require lodash first: var _ = require('lodash');

@lmartins
Copy link
Author

Ok, updated node to 0.10.29 and required lodash in the gulpfile. Also had to install gulp-consolidate plugin and now it returns:

[gulp] Using gulpfile ~/Sites/idomlive.com/.src/gulpfile.js
[gulp] Starting 'icons'...
[gulp] Finished 'icons' after 174 ms
[09:34:50] gulp-svgicons2svgfont:  Font created!

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
TypeError: Object function lodash(value) {
      // don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
      return (value && typeof value == 'object' && !isArray(value) && hasOwnProperty.call(value, '__wrapped__'))
       ? value
       : new lodashWrapper(value);
    } has no method 'template'
    at Function.exports.lodash.render (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-consolidate/node_modules/consolidate/lib/consolidate.js:537:56)
    at /Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-consolidate/node_modules/consolidate/lib/consolidate.js:146:25
    at /Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-consolidate/node_modules/consolidate/lib/consolidate.js:99:5
    at fs.js:271:14
    at /Users/luismartins/Sites/idomlive.com/.src/node_modules/assemble/node_modules/gray-matter/node_modules/fs-utils/node_modules/graceful-fs/graceful-fs.js:104:5
    at /Users/luismartins/Sites/idomlive.com/.src/node_modules/webpack/node_modules/enhanced-resolve/node_modules/graceful-fs/graceful-fs.js:104:5
    at Object.oncomplete (fs.js:107:15)

Despite the error, it did created two font files (svg and ttf), but it seems it didn't finish because some formats missing and no css was generated.

@backflip
Copy link
Owner

What happens if you bypass gulp-consolidate using gulp-tap, .e.g.:

'use strict';

var gulp = require('gulp'),
    plugins = require('gulp-load-plugins')(),
    _ = require('lodash');

gulp.task('icons', function(){
    return gulp.src(config.ICONS.src)
        .pipe(plugins.iconfont({
            fontName: config.ICONS.fontname,
            fixedWidth: true,
            appendCodepoints: false
        }).on('codepoints', function(codepoints, options) {
            gulp.src('./sass/app/components/icons/_icons-template.scss')
                .pipe(plugins.tap(function(file) {
                    var templateData = {
                            fontName: options.fontName,
                            fontPath: '/fonts/',
                            glyphs: _.map(codepoints, function(codepoint) {
                                return {
                                    fileName: codepoint.name,
                                    codePoint: codepoint.codepoint.toString(16).toUpperCase()
                                };
                            })
                        };

                    file.contents = new Buffer(_.template(file.contents.toString(), templateData));

                    return file;
                }))
                .pipe(gulp.dest('./sass/app/components/icons/_icons.scss'));
        }))
        .pipe(gulp.dest(config.ICONS.build));
});

@lmartins
Copy link
Author

First I had to require gulp-tap directly because the plugins loader for some reason wasn't pulling it.
Then, i get:

[gulp] Using gulpfile ~/Sites/idomlive.com/.src/gulpfile.js
[gulp] Starting 'icons'...
[09:58:34] gulp-svgicons2svgfont:  Font created!

/Users/luismartins/Sites/idomlive.com/.src/gulpfile.js:227
          file.contents = new Buffer(_.template(file.contents.toString(), temp
                                       ^
TypeError: Object function lodash(value) {
      // don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
      return (value && typeof value == 'object' && !isArray(value) && hasOwnProperty.call(value, '__wrapped__'))
       ? value
       : new lodashWrapper(value);
    } has no method 'template'
    at /Users/luismartins/Sites/idomlive.com/.src/gulpfile.js:227:40
    at Stream.modifyFile (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-tap/lib/tap.js:66:11)
    at Stream.stream.write (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-tap/node_modules/event-stream/node_modules/through/index.js:26:11)
    at write (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:605:24)
    at flow (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:614:7)
    at Transform.pipeOnReadable (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:646:5)
    at Transform.emit (events.js:92:17)
    at emitReadable_ (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:430:10)
    at emitReadable (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:426:5)
    at readableAddChunk (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:187:9)

Sorry for all the trouble :-(

@backflip
Copy link
Owner

Something's wrong with your lodash. What's the output of console.log(_);?

@lmartins
Copy link
Author

humm..

I get the following:

function lodash(value) {
          // don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
          return (value && typeof value == 'object' && !isArray(value) && hasOwnProperty.call(value, '__wrapped__'))
           ? value
           : new lodashWrapper(value);
        } 

That's weird, just reinstalled it from NPM and it still outputs the same.

@backflip
Copy link
Owner

What's the output of npm ls lodash in the console?

@lmartins
Copy link
Author

That would be:

├─┬ [email protected]
│ └─┬ [email protected]
│   ├─┬ [email protected]
│   │ ├─┬ [email protected]
│   │ │ ├─┬ [email protected]
│   │ │ │ └── [email protected]
│   │ │ └─┬ [email protected]
│   │ │   └── [email protected]
│   │ └─┬ [email protected]
│   │   └── [email protected]
│   └── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ └─┬ [email protected]
│   └─┬ [email protected]
│     └─┬ [email protected]
│       └─┬ [email protected]
│         └── [email protected]
├─┬ [email protected]
│ └─┬ [email protected]
│   └─┬ [email protected]
│     └── [email protected]
├─┬ [email protected]
│ └─┬ [email protected]
│   └─┬ [email protected]
│     └─┬ [email protected]
│       └─┬ [email protected]
│         └── [email protected]
├─┬ [email protected]
│ └─┬ [email protected]
│   └─┬ [email protected]
│     └── [email protected]
└── [email protected]

@backflip
Copy link
Owner

What if you run my reduced example from above (without any other tasks)?

@lmartins
Copy link
Author

Now it did created 4 font files, didn't update the CSS, but it returned:

[gulp] Using gulpfile ~/Sites/idomlive.com/.src/gulpfile.js
[gulp] Starting 'icons'...
[10:14:33] gulp-svgicons2svgfont:  Font created!
[gulp] Finished 'icons' after 486 ms

/Users/luismartins/Sites/idomlive.com/.src/gulpfile.js:227
                    file.contents = new Buffer(_.template(file.contents.toStri
                                                 ^
TypeError: Object function lodash(value) {
      // don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
      return (value && typeof value == 'object' && !isArray(value) && hasOwnProperty.call(value, '__wrapped__'))
       ? value
       : new lodashWrapper(value);
    } has no method 'template'
    at /Users/luismartins/Sites/idomlive.com/.src/gulpfile.js:227:50
    at Stream.modifyFile (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-tap/lib/tap.js:66:11)
    at Stream.stream.write (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-tap/node_modules/event-stream/node_modules/through/index.js:26:11)
    at write (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:605:24)
    at flow (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:614:7)
    at Transform.pipeOnReadable (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:646:5)
    at Transform.emit (events.js:92:17)
    at emitReadable_ (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:430:10)
    at emitReadable (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:426:5)
    at readableAddChunk (/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:187:9)

@backflip
Copy link
Owner

Just to be sure: Can you install nvm, run v0.10.29, delete node_modules and run npm install again?

What platform are you on?

@lmartins
Copy link
Author

Im not using NVM, upgraded node directly. node -v returns v0.10.29. Should I still install nvm?
Im on OSX 10.9 and after reinstalling all npm_modules it still outputs the same error.

@backflip
Copy link
Owner

The advantage of nvm would be to have a standardized environment (in case something was wrong with your node installation).

Other idea: What's the output if you create a file test.js with the following content and run node test.js?

var _ = require('lodash');
console.log(_);

@lmartins
Copy link
Author

running node test.s returns:

{ [Function: lodash]
  support: { funcDecomp: true, funcNames: true },
  after: [Function: after],
  assign: [Function],
  at: [Function: at],
  bind: [Function: bind],
  bindAll: [Function: bindAll],
  bindKey: [Function: bindKey],
  chain: [Function: chain],
  compact: [Function: compact],
  compose: [Function: compose],
  constant: [Function: constant],
  countBy: [Function],
  create: [Function: create],
  createCallback: [Function: createCallback],
  curry: [Function: curry],
  debounce: [Function: debounce],
  defaults: [Function],
  defer: [Function: defer],
  delay: [Function: delay],
  difference: [Function: difference],
  filter: [Function: filter],
  flatten: [Function: flatten],
  forEach: [Function: forEach],
  forEachRight: [Function: forEachRight],
  forIn: [Function],
  forInRight: [Function: forInRight],
  forOwn: [Function],
  forOwnRight: [Function: forOwnRight],
  functions: [Function: functions],
  groupBy: [Function],
  indexBy: [Function],
  initial: [Function: initial],
  intersection: [Function: intersection],
  invert: [Function: invert],
  invoke: [Function: invoke],
  keys: [Function],
  map: [Function: map],
  mapValues: [Function: mapValues],
  max: [Function: max],
  memoize: [Function: memoize],
  merge: [Function: merge],
  min: [Function: min],
  omit: [Function: omit],
  once: [Function: once],
  pairs: [Function: pairs],
  partial: [Function: partial],
  partialRight: [Function: partialRight],
  pick: [Function: pick],
  pluck: [Function: map],
  property: [Function: property],
  pull: [Function: pull],
  range: [Function: range],
  reject: [Function: reject],
  remove: [Function: remove],
  rest: [Function: rest],
  shuffle: [Function: shuffle],
  sortBy: [Function: sortBy],
  tap: [Function: tap],
  throttle: [Function: throttle],
  times: [Function: times],
  toArray: [Function: toArray],
  transform: [Function: transform],
  union: [Function: union],
  uniq: [Function: uniq],
  values: [Function: values],
  where: [Function: filter],
  without: [Function: without],
  wrap: [Function: wrap],
  xor: [Function: xor],
  zip: [Function: zip],
  zipObject: [Function: zipObject],
  collect: [Function: map],
  drop: [Function: rest],
  each: [Function: forEach],
  eachRight: [Function: forEachRight],
  extend: [Function],
  methods: [Function: functions],
  object: [Function: zipObject],
  select: [Function: filter],
  tail: [Function: rest],
  unique: [Function: uniq],
  unzip: [Function: zip],
  clone: [Function: clone],
  cloneDeep: [Function: cloneDeep],
  contains: [Function: contains],
  escape: [Function: escape],
  every: [Function: every],
  find: [Function: find],
  findIndex: [Function: findIndex],
  findKey: [Function: findKey],
  findLast: [Function: findLast],
  findLastIndex: [Function: findLastIndex],
  findLastKey: [Function: findLastKey],
  has: [Function: has],
  identity: [Function: identity],
  indexOf: [Function: indexOf],
  isArguments: [Function: isArguments],
  isArray: [Function: isArray],
  isBoolean: [Function: isBoolean],
  isDate: [Function: isDate],
  isElement: [Function: isElement],
  isEmpty: [Function: isEmpty],
  isEqual: [Function: isEqual],
  isFinite: [Function: isFinite],
  isFunction: [Function: isFunction],
  isNaN: [Function: isNaN],
  isNull: [Function: isNull],
  isNumber: [Function: isNumber],
  isObject: [Function: isObject],
  isPlainObject: [Function],
  isRegExp: [Function: isRegExp],
  isString: [Function: isString],
  isUndefined: [Function: isUndefined],
  lastIndexOf: [Function: lastIndexOf],
  mixin: [Function: mixin],
  noConflict: [Function: noConflict],
  noop: [Function: noop],
  now: [Function: now],
  parseInt: [Function],
  random: [Function: random],
  reduce: [Function: reduce],
  reduceRight: [Function: reduceRight],
  result: [Function: result],
  runInContext: [Function: runInContext],
  size: [Function: size],
  some: [Function: some],
  sortedIndex: [Function: sortedIndex],
  unescape: [Function: unescape],
  uniqueId: [Function: uniqueId],
  all: [Function: every],
  any: [Function: some],
  detect: [Function: find],
  findWhere: [Function: find],
  foldl: [Function: reduce],
  foldr: [Function: reduceRight],
  include: [Function: contains],
  inject: [Function: reduce],
  first: [Function: first],
  last: [Function: last],
  sample: [Function: sample],
  take: [Function: first],
  head: [Function: first],
  VERSION: '2.4.1',
  _: [Circular] }

@backflip
Copy link
Owner

Okay, so what if you add console.log(_) to the end of your gulpfile.js and run node gulpfile.js? If you have your error again, you could start deleting stuff from gulpfile.js to pinpoint the trigger of this weird behavior.

@lmartins
Copy link
Author

I've stripped the gulp file down to just the font generation stuff:
https://gist.github.com/lmartins/f9f2f130ae03d511e674

Unfortunately the result is the same.

[gulp] Starting 'icons'...
[gulp] Finished 'icons' after 18 ms

/Users/luismartins/Sites/idomlive.com/.src/node_modules/gulp-iconfont-css/index.js:104
                        throw error;
                              ^
TypeError: Object function lodash(value) {
      // don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
      return (value && typeof value == 'object' && !isArray(value) && hasOwnProperty.call(value, '__wrapped__'))
       ? value
       : new lodashWrapper(value);
    } has no method 'template'
    at Function.exports.lodash.render (/Users/luismartins/Sites/idomlive.com/.src/node_modules/consolidate/lib/consolidate.js:537:56)
    at /Users/luismartins/Sites/idomlive.com/.src/node_modules/consolidate/lib/consolidate.js:146:25
    at /Users/luismartins/Sites/idomlive.com/.src/node_modules/consolidate/lib/consolidate.js:99:5
    at fs.js:271:14
    at Object.oncomplete (fs.js:107:15)

Im sorry for all the trouble, don't want to trouble you more with this. I might resort to use the older version and hope this might solve itself in the near future.

@backflip
Copy link
Owner

Can you upload your node_modules folder somewhere?

It is really weird that it works with an older version of the plugin but you have the same error when bypassing it using gulp-tap. What if you use gulp-tap and remove gulp-iconfont-css from the package.json (so gulp-load-plugins won't pick it up)?

@lmartins
Copy link
Author

I've just placed the node_modules folder on Dropbox, should be available at:
http://dl.dropbox.com/u/29267/Uploads/node_modules.zip

The test you suggest still outputs the same error.

Also made another test, using the example in the gulp-iconfontplugin:

I've noticed that if I pass an invalid path as gulp.src to the on function it compiles without error, but no CSS created. Once I pass a correct path then it retrieves the same error message.

gulp.task('icons', function(){
    return gulp.src(config.ICONS.src)
        .pipe(plugins.iconfont({
            fontName: config.ICONS.fontname,
            fixedWidth: true,
            appendCodepoints: false
        }).on('codepoints', function(codepoints, options) {
            gulp.src('sas1s/app/components/icons/_icons.scss')
            .pipe(plugins .consolidate('lodash', {
              glyphs: codepoints,
              fontName: 'icons',
              fontPath: './fonts/',
              className: 'icon'
            }))
            .pipe(gulp.dest('www/css/'));
        }))
        .pipe(gulp.dest(config.ICONS.build));
});

@backflip
Copy link
Owner

The package.json of your lodash module explains a lot: ""A private version of Lo-dash lib, without template() method to bypass CSP restrictions". Emmet might be the culprit: https://github.com/emmetio/lodash

@backflip
Copy link
Owner

Can you run npm cache clean before npm install to see whether you get the correct lodash version instead of the other one?

@lmartins
Copy link
Author

Wow, that was a nasty and unexpected consequence of using Emmet.
After cleaning and reinstalling it is now working.... Geezz.

Im owing you a coffee or something man. Thank you soo much for all the help.

@backflip
Copy link
Owner

You are welcome!

Good to know that npm cache clean can solve about everything. :)

@macbleser
Copy link

Just wanted to let you guys know that I was having a similar error which I was able to resolve by running npm cache clean, wiping my node_modules directory, then running npm install.

Thanks for documenting your fix here and enlightening me about the power of npm cache clean!

@jdempcy
Copy link

jdempcy commented Dec 19, 2014

The following fixed a bug I was having trying to get angular-fullstack-crud working, with a caveat being that I had to run it from within a subdirectory of the root node_modules for the project. So if it isn't working, look for a nested node_modules directory within one of the subdirectories of the highest-level node_moduels (from project root) and try running it there:

rm -rf node_modules && npm cache clean && npm install

I generated angular-fullstack and then navigated to that directory, added a config.json, installed generator-angular-fullstack-crud. When I tried running yo angular-fullstack-crud it gave me an error:

Error: Cannot find module 'yeoman-generator/node_modules/lodash'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/jonah/Development/bluefire/sandbox/angular-fullstack-crud/node_modules/generator-angular-fullstack-crud/app/index.js:7:9)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)

I could fix this by running npm install from the /node_modules/generator-angular-fullstack-crud/ directory, but it wasn't a good fix because I still ran into this error:

writing: client/components/navbar/navbar.controller.js
writing: server/routes.js
writing: client/app/app.js
error generating files:  [TypeError: Object function lodash(value) {
  // don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
  return (value && typeof value == 'object' && !isArray(value) && hasOwnProperty.call(value, '__wrapped__'))
   ? value
   : new lodashWrapper(value);
} has no method 'slugify']

I finally really got the angular-fullstack-crud generator working with:

$ cd node_modules/generator-angular-fullstack-crud/ && rm -rf node_modules && npm cache clean && npm install

Thanks for letting me know about the magic of npm cache clean!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants