lovell / sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
https://sharp.pixelplumbing.com
Apache License 2.0
29.25k stars 1.3k forks source link

Meteor: "Unable to resolve some modules" #537

Closed Nico-L closed 8 years ago

Nico-L commented 8 years ago

Hi,

I would like to use sharp for image manipulation in a meteor project I am working on. I add the sharp dependency in my package.json: "sharp": "^0.15.1"

I didn't add any dependencies

When start the app, I have this error:

Unable to resolve some modules:

  "path" in /mnt/vdb/web/site-LBF/node_modules/sharp/index.js (web.browser)
  "util" in /mnt/vdb/web/site-LBF/node_modules/sharp/index.js (web.browser)
  "stream" in /mnt/vdb/web/site-LBF/node_modules/sharp/index.js (web.browser)
  "events" in /mnt/vdb/web/site-LBF/node_modules/sharp/index.js (web.browser)
  "./build/Release/sharp" in /mnt/vdb/web/site-LBF/node_modules/sharp/index.js (web.browser)

Theses modules are not the dependencies listed in the npm page. I tried to add the dependencies to the package.json:

"tar": "^2.2.1", 
    "request": "^2.74.0", 
    "semver": "^5.3.0", 
    "nan": "^2.4.0", 
    "color": "^0.11.3", 
    "bluebird": "^3.4.1",
    "sharp": "^0.15.1"

It doesn't change anything.

Am I missing any prerequisites ?

Thanks

lovell commented 8 years ago

Hello, those modules are provided by node.

https://github.com/meteor/node-stubs https://guide.meteor.com/1.3-migration.html#modules

Nico-L commented 8 years ago

Hi Lovell,

Thanks, indeed installing node-stubs fixed the issue.

Now I have a different problem:

Unable to resolve some modules:

  "./build/Release/sharp" in /mnt/vdb/web/site-LBF/node_modules/sharp/index.js (web.browser)

I have uninstalled and re-installed sharp several times with not much success, through package.json and manually npm install sharp. And indeed, there is no sharp directory under /build/Release/. I have looked into past issues here but nothing that helped me.

Would you have an idea?

Thanks

lovell commented 8 years ago

I have no experience of Meteor.

https://guide.meteor.com/using-npm-packages.html suggests meteor npm install should be run.

Is there any useful error or debug information when running meteor npm install sharp?

Nico-L commented 8 years ago

Thank you for having done these research. I tried npm install and meteor npm install. logSharpInstall is the verbose log of meteor npm install --verbose. logSharpInstall.txt

The following log corresponds to the meteor npm install sharp --verbose command logSharpInstallManual.txt

Oddly enough, this isn't much of a big red error.

Thanks

lovell commented 8 years ago

https://github.com/meteor/meteor/issues/6726 might be relevant but you're way beyond my knowledge of Meteor.

Let's leave this question open in case others can help.

isjackwild commented 8 years ago

Hey, having the same problem here — wondering if anyone's found a solution?

ogermann commented 8 years ago

same here

Nico-L commented 8 years ago

I did not find any solution. I ended up using the cfs:imagemagicks Meteor package

isjackwild commented 8 years ago

I found a 'solution':

$ cd node_modules/sharp/build/Release $ ln -s sharp.node sharp

ogermann commented 8 years ago

I took Nico-L' way and switched to graphicsmagick... works fine

lovell commented 8 years ago

Thank you @isjackwild, your workaround has just provided the inspiration for a solution.

It looks like Meteor doesn't add the .node extension in its (custom?) implementation of require() like Node does - https://nodejs.org/api/all.html#addons_loading_addons_using_require

Changing https://github.com/lovell/sharp/blob/master/index.js#L12 to explicitly include the .node might fix this.

- var sharp = require('./build/Release/sharp');
+ var sharp = require('./build/Release/sharp.node');

I'll need to test this to ensure everything else still works cross-platform.

isjackwild commented 8 years ago

Awesome news! Fingers crossed that works…

I spent hours trying to figure this one out. ;)

On 5 Oct 2016, at 10:23, Lovell Fuller notifications@github.com<mailto:notifications@github.com> wrote:

Thank you @isjackwildhttps://github.com/isjackwild, your workaround has just provided the inspiration for a solution.

It looks like Meteor doesn't add the .node extension in its (custom?) implementation of require() like Node does - https://nodejs.org/api/all.html#addons_loading_addons_using_require

Changing https://github.com/lovell/sharp/blob/master/index.js#L12 to explicitly include the .node might fix this.

I'll need to test this to ensure everything else still works cross-platform.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/lovell/sharp/issues/537#issuecomment-251625239, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFf8D75EhJRV9WCP1sbYY-2dnsjATb6zks5qw2ycgaJpZM4Jbzsc.

lovell commented 8 years ago

Commit 739178d explicitly adds the .node extension that is lacking in Meteor's require() implementation, intentionally or otherwise.

Everything appears to still work when require()d by Node on Linux, OS X and Windows.

Is anyone able to test this with Meteor?

lovell commented 8 years ago

/cc @DrDanRyan

lovell commented 8 years ago

This enhancement is in v0.16.1, now available via npm.