atticoos / gulp-ng-config

:wrench: Create AngularJS constants from a JSON config file
MIT License
173 stars 35 forks source link

TypeError: _.contains is not a function issue with lodash 4.0 #58

Closed zymr-keshav closed 7 years ago

zymr-keshav commented 8 years ago

i have "lodash": "~4.0.0" and "gulp-ng-config": "^1.3.1"

created a task

gulp.task('env', function () {
  gulp.src(path.join(conf.paths.src, 'env.json'))
  .pipe($.ngConfig('app', {
    createModule: false,
    wrap: true
  }))
  .pipe(gulp.dest(path.join(conf.paths.src, '/app/')));
});

but when i run gulp env; it gives error

/opt/baffle-manager/WebUI/node_modules/gulp-ng-config/gulp-ng-config.js:83
    if (!_.contains(VALID_TYPES, configuration.type)) {
           ^

TypeError: _.contains is not a function
    at DestroyableTransform._transform (/opt/my-project/WebUI/node_modules/gulp-ng-config/gulp-ng-config.js:83:12)
    at DestroyableTransform.Transform._read (/opt/my-project/WebUI/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:159:10)
    at DestroyableTransform.Transform._write (/opt/my-project/WebUI/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:147:83)
    at doWrite (/opt/my-project/WebUI/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:313:64)
    at writeOrBuffer (/opt/my-project/WebUI/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:302:5)
    at DestroyableTransform.Writable.write (/opt/my-project/WebUI/node_modules/through2/node_modules/readable-stream/lib/_stream_writat DestroyableTransform._transform (/opt/my-project/WebUI/node_modules/gulp-ng-config/gulp-ng-config.js:83:12)
    at DestroyableTransform.Transform._read (/opt/my-project/WebUI/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:159:10)
    at DestroyableTransform.Transform._write (/opt/my-project/WebUI/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:147:83)
    at doWrite (/opt/my-project/WebUI/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:313:64)
    at writeOrBuffer (/opt/my-project/WebUI/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:302:5)
    at DestroyableTransform.Writable.write (/opt/my-project/WebUI/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:241:11)
    at write (/opt/my-project/WebUI/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:623:24)
    at flow (/opt/my-project/WebUI/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:632:7)
    at DestroyableTransform.pipeOnReadable (/opt/my-project/WebUI/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:664:5)
    at emitNone (events.js:86:13)
    at DestroyableTransform.emit (events.js:185:7)
    at emitReadable_ (/opt/my-project/WebUI/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:448:10)
    at emitReadable (/opt/my-project/WebUI/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:444:5)
    at readableAddChunk (/opt/my-project/WebUI/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:187:9)
    at DestroyableTransform.Readable.push (/opt/my-project/WebUI/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:149:10)
    at DestroyableTransform.Transform.push (/opt/my-project/WebUI/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_transform.js:145:32)
zymr-keshav commented 8 years ago

it has been solved when I add gulp-ng-config inside "devDependencies" block in package.json and run npm install --no-optional . this will add lodash 3.10.x and now working fine.

PizzaPete commented 7 years ago

This is also an issue with the project I work on. Jenkins builds fail because of the lodash version.

The solution from @zymr-keshav won't work for us since we need gulp-ng-config as a dependency and not as a devDependency.

atticoos commented 7 years ago

Hey @PizzaPete - I assume the best way to reproduce this is to create a project with a 4.x lodash dependency along with gulp-ng-config?

PizzaPete commented 7 years ago

@ajwhite your assumption is correct.

gulp-ng-config.js has a _.contains function on line 83 that fails. It might be as simple as changing _.contains with _.includes. But I'm not sure if this breaks anything else.

ygrene-austin commented 7 years ago

This should be pretty simple right?

PizzaPete commented 7 years ago

@ygrene-austin could be pretty simple. If it is just replacing _.contains with _.includes. The workaround for our team was to use lodash 3.x