mgonto / restangular

AngularJS service to handle Rest API Restful Resources properly and easily
MIT License
7.87k stars 840 forks source link

Lodash 4.0 TypeError: _.contains is not a function #1294

Closed yoshuacas closed 8 years ago

yoshuacas commented 8 years ago

I noticed that lodash 4.0 was released 2 days ago, and also noticed that Restangular no longer works..

I receive TypeError: _.contains is not a function.

In the code of lodash you can see how the _.contains alias was removed, will you guys update something? I don't want to have crazy fixes made in my code.

yoshuacas commented 8 years ago

I've made the following in my project in the meantime:

bower uninstall restangular bower uninstall lodash bower install --save lodash#3.10.1 bower install --save restangular

vikasrohit commented 8 years ago

I started to get the same error because restangular is having dependency on lodash >= '1.3.0'

sssilver commented 8 years ago

Having a related problem.

λ ~/projects/angler/hook/ master* bower list
bower check-new     Checking for new versions of the project dependencies...
scool#0.0.0 /Users/aharutyunyan/projects/angler/hook
├── angular#1.4.8 (1.5.0-rc.0 available)
├─┬ angular-bootstrap#1.0.3
│ └── angular#1.4.8 (1.5.0-rc.0 available)
├─┬ angular-cookies#1.4.8 (1.5.0-rc.0 available)
│ └── angular#1.4.8 (latest is 1.5.0-rc.0)
├─┬ angular-resource#1.4.8 extraneous (1.5.0-rc.0 available)
│ └── angular#1.4.8
├─┬ angular-route#1.4.8 (1.5.0-rc.0 available)
│ └── angular#1.4.8
├─┬ angular-ui-router#0.2.15
│ └── angular#1.4.8 (1.5.0-rc.0 available)
├─┬ angular-ui-select2#0.0.5
│ ├── angular#1.4.8 (1.5.0-rc.0 available)
│ ├── jquery#2.2.0 (3.0.0-alpha1+compat available)
│ └─┬ select2#3.4.8 (latest is 4.0.1)
│   └── jquery#2.2.0 (3.0.0-alpha1+compat available)
├─┬ bootstrap#3.3.6 (4.0.0-alpha.2 available)
│ └── jquery#2.2.0 (latest is 3.0.0-alpha1+compat)
├── font-awesome#4.5.0
└─┬ restangular#1.5.1
  ├── angular#1.4.8 (1.5.0-rc.0 available)
  └── lodash#4.0.0

App fails to GET http://localhost/projects/angler/hook/lib/lodash/lodash.min.js, which returns a 404.

And sure enough:

λ ~/projects/angler/hook/ master* l lib/lodash/lodash*
-rw-r--r--  1 aharutyunyan  staff   449K Jan 12 10:34 lib/lodash/lodash.js

...a file called lodash.min.js simply doesn't exist.

derekgreer commented 8 years ago

This is probably understood given the error, but lodash uses semantic versioning which restangular isn't respecting within its bower.json file. That needs to be changed to be > 3.10.1 and < 4.0.0

rbatllet commented 8 years ago

The bower support has been removed in Lodash 4.0.0 in favor of npm:

https://github.com/lodash/lodash/wiki/Changelog

nitish24p commented 8 years ago

Any solution for this issue?

yourcontainer commented 8 years ago

I have a some problem with this issue, it is critical for my project, can you fix it, please?

jadjoubran commented 8 years ago

@nitish24p @yourcontainer you can use the fix suggested by @yoshuacas I applied the fix and it works.

xeor commented 8 years ago

The fix is really simple. This is a dupe of #1298 The fix is as simple as https://github.com/xeor/restangular/commit/16d69aff50a9182d7582836388f6e403851673ca

Frank3K commented 8 years ago

@xeor: can you make a PR? I think your fix is better than #1295.

xeor commented 8 years ago

Sorry for the delay, but https://github.com/mgonto/restangular/pull/1301 is created

lougaou commented 8 years ago

+1

rbatllet commented 8 years ago

It seems that Restangular has been completely abandoned by @mgonto. What a pity!

ConcurrentHashMap commented 8 years ago

Hey all,

I'm in contact to @mgonto and told him about all the confusion going on here. He will shortly open up a separate issue to write about the situation of Restangular. Please stay tuned for that. I'm in a good mood that there is a future for the maintenance of Restangular!

xeor commented 8 years ago

The new Http module in angular2 have gotten much more love than the one we had in angular1. It makes me think that restangular have done its job keeping us all sane using angular1, (which I think we are all very happy for). They might think that we can move on to using the native Http library from now. Just some thoughts... Lets wait for a more official answer from @mgonto :)

rbatllet commented 8 years ago

But what happens to angular 1.x and the bugs related to the new Lodash 4.x, @xeor?

ConcurrentHashMap commented 8 years ago

Good news - the issue is fixed by the recently released v1.5.2.

@rbatllet Please read on #1319 for this. I will try to do my best maintaining restangular 1.x, maybe @xeor will also be available to help me with that? :) I see he is very active in this repository and maybe he would also like to do further development for the next major release of restangular?

Thanks to everyone for reporting bugs and doing awesome pull requests!

niemyjski commented 8 years ago

@ConcurrentHashMap I don't see how 1.5.2 fixed anything. The change list only shows the readme as being updated :(. I ran the lodash-migrate script and I'm seeing a bunch of warnings for reduce.

lodash-migrate.js:163 lodash-migrate: _.reduce([ [ route: 'projects', getRestangularUrl: [Function: wrapper], getRequestedUr...)
  v3.10.1 => 'https://api.xxx.io/api/v2/projects'
  v4.4.0 => 'https://api.xxx.io/api/v2/undefined'

https://github.com/exceptionless/Exceptionless.UI/tree/feature/chart-options

ConcurrentHashMap commented 8 years ago

@niemyjski Which change list do you mean? I updated the changelog and added the 1.5.2 tag to the commit that changed the obsolete functions to the right ones.

To reproduce your problem, could you explain which lodash version you were on before? I didn't use the lodash-migrate before.

For now the best would be to fix the lodash version to 3.10.1, this shouldn't do any problems or did you experience other issues?

Sorry for the problems you currently experience; I was afraid that my release would break something, but the good part of it is, that we're finally moving forward with small steps now! Thanks to you!

niemyjski commented 8 years ago

I was looking at the commits since this release instead of (https://github.com/mgonto/restangular/compare/1.5.1...1.5.2).. My bad.. I was on 3.10.1 and then upgraded to latest and used the migration plugin and it told me about those in the console.

Yeah no problem! I figured it would be good to let you guys know :)

nitish24p commented 8 years ago

How do i unsuscribe to this mail thread :\

On Wed, Feb 17, 2016 at 9:07 PM, Blake Niemyjski notifications@github.com wrote:

I was looking at the commits since this release instead of (1.5.1...1.5.2 https://github.com/mgonto/restangular/compare/1.5.1...1.5.2).. My bad.. I was on 3.10.1 and then upgraded to latest and used the migration plugin and it told me about those in the console.

Yeah no problem! I figured it would be good to let you guys know :)

— Reply to this email directly or view it on GitHub https://github.com/mgonto/restangular/issues/1294#issuecomment-185259559 .


Download Practo App http://go.onelink.me/1025359428?pid=Email&c=practoemailsignature

niemyjski commented 8 years ago

@nitish24p The big unsubscribe button on the right hand side.

niemyjski commented 8 years ago

@ConcurrentHashMap Any ideas on this?

niemyjski commented 8 years ago

Everything appears to be working, but a bit worried about those messages from lodash-migrate.

YassineFadhlaoui commented 8 years ago

sorry for this late answer This famous issue can be easily solved by adding this script to your index.html file after including lodash :

<script>
     _.contains = _.includes;
    </script>

or you can browse the restangular.js file and change .contains by .includes but i prefer the second solution it's more effective

niemyjski commented 8 years ago

Not really feasible solution..

brendon-colburn commented 8 years ago

@niemyjski why do you consider this not feasible? The solution works well for me although it's admittedly very work-aroundish. Mgonto has mentioned elsewhere on the forums that he won't be actively maintaining moving forward and has asked that the community step up in that regard. So if you have an idea of a better way to do this please share. Thanks!

niemyjski commented 8 years ago

@brendon-colburn get commit access and fix the real issue :)

brendon-colburn commented 8 years ago

I stand somewhat corrected after discovering this thing called reading past threads, haha. So 1.5.2 accomplishes the same thing @YassineFadhlaoui suggested. I've been on 1.4 because no one has updated nuget and I'm in the .NET visual studio world. I'll manually update, begrudgingly. @niemyjski I noticed that you were getting issues in regards to your lodash-migrate which I learned today is a way of keeping your lodash library up to date. My (probably antiquated, thanks .NET community) version of lodash doesn't throw any console errors my way.