cornerstoneWADOImageLoader icon indicating copy to clipboard operation
cornerstoneWADOImageLoader copied to clipboard

Can't resolve `fs` in cornerstone-wado-image-loader in 3.0.0

Open mikehazell opened this issue 5 years ago • 10 comments

Getting this error when building my app.

ERROR in /Users/.../ProjectName/node_modules/cornerstone-wado-image-loader/dist/cornerstoneWADOImageLoader.min.js
Module not found: Error: Can't resolve 'fs' in '/Users/.../ProjectName/node_modules/cornerstone-wado-image-loader/dist'

I'm am using Next.js which has a default webpack config. Luckily this issue can be resolved on my end by adding to following to the webpack config.

// next.config.js
export {
  webpack(config) {
    config.externals = { fs: 'commonjs fs' };
    return config;
  }
}

Can this be resolved in the package?

mikehazell avatar Aug 20 '19 14:08 mikehazell

👋 Hi @mikehazell, long time no see.

Can this be resolved in the package?

I'm not sure. I see that we have it in our own config here:

  • https://github.com/cornerstonejs/cornerstoneWADOImageLoader/blob/master/config/webpack/webpack-base.js#L83

I'm not 100% sure what's causing the issue. Some of the decoders for this library are imported "as is". It's possible we're not trimming some node specific imports from them, Pako, or something in the WebWorker space.

If we can identify the cause, I might be able to prioritize getting a solution in place.

dannyrb avatar Aug 20 '19 15:08 dannyrb

I started having a similar issue after updating to 3.0.0, it's caused by some of the codecs requiring fs: charLS-FixedMemory-browser.js openJPEG-FixedMemory.js

fs may be used by their dependencies, I just noticed that those codecs had a require("fs") in the final bundle.

Meta-Maxim avatar Sep 10 '19 17:09 Meta-Maxim

I was able to fix this by adding node: { fs: 'empty' } to my webpack config. Thanks for the tip guys.

sedenardi avatar Sep 25 '19 21:09 sedenardi

I was able to fix this by adding node: { fs: 'empty' } to my webpack config. Thanks for the tip guys.

+1 this decision helped for me too, thanks

fomin-max avatar Nov 10 '19 14:11 fomin-max

I was able to fix this by adding node: { fs: 'empty' } to my webpack config. Thanks for the tip guys.

I did the same, but no luck , I am still getting the error

sp1805 avatar Nov 22 '19 06:11 sp1805

I am also getting this error.

adamwdennis avatar May 04 '20 11:05 adamwdennis

Didn't work for me. I have node: { fs: 'empty' } but still get that error.

desprit avatar Oct 07 '20 11:10 desprit

I had the same issue in my angular project. resolved with "fs": false in browser entry in package.json

elimb avatar Oct 07 '20 13:10 elimb

I'm using cornerstone with storybooks. And this is mainly storybooks that's causing problem. Long story short: https://stackoverflow.com/a/64246289/3459479

desprit avatar Oct 07 '20 13:10 desprit

Hi!

I was getting the same error with 'fs' and 'path'

Module not found: Error: Can't resolve 'fs' in '/Users/.../dev/.../node_modules/cornerstone-wado-image-loader/dist'
...

Module not found: Error: Can't resolve 'path' in '/Users/.../dev/.../node_modules/cornerstone-wado-image-loader/dist'

I was able to fix this error by adding the following code to my webpack.config.js

resolve: {
    fallback: { fs: false, path: false },
},

hope this helps!

facuescobar avatar Nov 03 '20 17:11 facuescobar