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

Bookshelf does not work with lodash 4.0+ #1264

Closed
ahmedcanuck opened this Issue May 25, 2016 · 8 comments

Comments

Projects
None yet
4 participants
@ahmedcanuck
Copy link

ahmedcanuck commented May 25, 2016

We recently upgraded our lodash version to 4.13.1 to be able to use new lodash features/options but now Bookshelf is returning the error:

module.js:327
throw err;
^

Error: Cannot find module 'lodash/array/flatten'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/Users/booradley/WebstormProjects/fifteenfourtynine/node_modules/bookshelf/lib/base/events.js:35:16)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/Users/booradley/WebstormProjects/fifteenfourtynine/node_modules/bookshelf/lib/bookshelf.js:15:15)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/Users/booradley/WebstormProjects/fifteenfourtynine/node_modules/bookshelf/bookshelf.js:8:18)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
[01:04:20] [nodemon] app crashed - waiting for file changes before starting...
[nodemon] app crashed - waiting for file changes before starting...

@rhys-vdw

This comment has been minimized.

Copy link
Contributor

rhys-vdw commented May 28, 2016

I don't understand this issue. Bookshelf is dependant on Lodash, version
matching "^3.8.0". That does not permit Lodash 4. npm should install as
many versions of Lodash as are needed for your project and its
dependencies. If npm is passing Lodash 4 to bookshelf then, as far as I
understand, this is a bug in npm. Am I missing something?

On Wed, May 25, 2016, 3:04 PM ahmedcanuck notifications@github.com wrote:

We recently upgraded our lodash version to 4.13.1 to be able to use new
lodash features/options but now Bookshelf is returning the error:

module.js:327
throw err;
^

Error: Cannot find module 'lodash/array/flatten'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.
(/Users/booradley/WebstormProjects/fifteenfourtynine/node_modules/bookshelf/lib/base/events.js:35:16)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.
(/Users/booradley/WebstormProjects/fifteenfourtynine/node_modules/bookshelf/lib/bookshelf.js:15:15)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.
(/Users/booradley/WebstormProjects/fifteenfourtynine/node_modules/bookshelf/bookshelf.js:8:18)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
[01:04:20] [nodemon] app crashed - waiting for file changes before
starting...
[nodemon] app crashed - waiting for file changes before starting...


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#1264

@ahmedcanuck

This comment has been minimized.

Copy link

ahmedcanuck commented May 28, 2016

Hey @rhys-vdw, this is what I'm seeing. Could possibly be something I'm missing with npm package options:

npm install
npm WARN package.json fifteenfourtynine@1.0.0 No README data
npm WARN unmet dependency /Users/booradley/WebstormProjects/fifteenfourtynine/node_modules/bookshelf requires lodash@'^3.8.0' but will load
npm WARN unmet dependency /Users/booradley/WebstormProjects/fifteenfourtynine/node_modules/lodash,
npm WARN unmet dependency which is version 4.13.1
npm WARN unmet dependency /Users/booradley/WebstormProjects/fifteenfourtynine/node_modules/checkit requires lodash@'^2.4.0 || ^3.0.0' but will load
npm WARN unmet dependency /Users/booradley/WebstormProjects/fifteenfourtynine/node_modules/lodash,
npm WARN unmet dependency which is version 4.13.1
npm WARN unmet dependency /Users/booradley/WebstormProjects/fifteenfourtynine/node_modules/knex requires lodash@'^3.7.0' but will load
npm WARN unmet dependency /Users/booradley/WebstormProjects/fifteenfourtynine/node_modules/lodash,
npm WARN unmet dependency which is version 4.13.1
@vellotis

This comment has been minimized.

Copy link
Contributor

vellotis commented May 28, 2016

I really liked the way NPM v2 handled packages. But it wasn't Windows friendly as it has MAX_PATH restriction.

NPM v3 to the "rescue". Now it doesn't have deep nested dependencies. It tries as much it is possible to install them in the root node_modules directory. But it may mess up the dependencies some times. I usually in these situations have deleted the node_modules directory and run npm install.

NPM 3 vs NPM 2

Still I'm not sure this is the solution.

@ErisDS

This comment has been minimized.

Copy link
Contributor

ErisDS commented Jun 13, 2016

We just upgraded Ghost to use lodash 4 and saw the same issue. To resolve it, we have to delete node_modules and re-run npm install. Then the issue goes away (this is on npm 2).

So essentially, npm can only make the right thing happen on a fresh install, re-running npm install on an existing set of dependences, or even npm update doesn't result in the right thing happening.

For sure this is a bug in npm, but unfortunately, npm is very buggy and getting them to fix things (and everyone to be on a bug-free version) is going to take quite some time 😉

Seeing as knex is now running on lodash 4, would it not make sense to work towards upgrading bookshelf as well? v4 seems to be quite a nice upgrade, with some great new tools.

Is there a reason for bookshelf being on the older version other than the fact the upgrade requires fiddly work to swap function names etc? Would this be something you'd be looking for a contrib for?

@rhys-vdw

This comment has been minimized.

Copy link
Contributor

rhys-vdw commented Jun 13, 2016

Is there a reason for bookshelf being on the older version other than the fact the upgrade requires fiddly work to swap function names etc? Would this be something you'd be looking for a contrib for?

@ErisDS if you're offering. 👍 Be careful though, we had a couple of bugs slip through in the Knex update.

@rhys-vdw

This comment has been minimized.

Copy link
Contributor

rhys-vdw commented Jun 13, 2016

Also I'm going to close this issue as I do not believe this to be a problem with Bookshelf. Happy to reopen if shown otherwise.

@rhys-vdw rhys-vdw closed this Jun 13, 2016

@rhys-vdw rhys-vdw added the invalid label Jun 13, 2016

@ErisDS

This comment has been minimized.

Copy link
Contributor

ErisDS commented Jun 13, 2016

It's not a problem with bookshelf, but expecting npm to fix things just doesn't work IMO 😉

The upgrade itself is still needed - can I raise a separate issue to get that done?

Also, I highly recommend turning on greenkeeper for both knex and bookshelf, although it creates a bit of repository noise, it makes keeping dependencies up-to-date much much easier because it takes the manual element out of it.

@rhys-vdw

This comment has been minimized.

Copy link
Contributor

rhys-vdw commented Jun 13, 2016

can I raise a separate issue to get that done?

Be my guest.

I highly recommend turning on greenkeeper for both knex and bookshelf

Hey, that's a neat tool. Thanks for the recommendation! 👍

@ErisDS ErisDS referenced this issue Jun 13, 2016

Closed

Fix Dependency Updates, once and for all ;) #1285

1 of 5 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment