PDBReader issue

Hi all,

here a newbie question. I’m having troubles with the PDBReader when importing:
import vtkPDBReader from ‘vtk.js/Sources/IO/Misc/PDBReader’;
the error is also with PDBReader example:
node_modules/vtk.js/Sources/IO/Misc/PDBReader/example/index.js
I tried to install stream-browserify and readable-stream, using:
npm install stream-browserify
npm install --save readable-stream

here the error I’m having:

ERROR in ./node_modules/jszip/lib/readable-stream-browser.js 9:0-34
Module not found: Error: Can’t resolve ‘stream’ in '/Users/mauro/node_modules/jszip/lib’
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { “stream”: require.resolve(“stream-browserify”) }'
- install 'stream-browserify’
If you don’t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { “stream”: false }

Any hint?
Cheers, Mauro

Solved it:

I installed stream-browserify with
npm install stream-browserify

and I modified webpack.config.js as:

var path = require('path');
var webpack = require('webpack');
var vtkRules = require('vtk.js/Utilities/config/dependency.js').webpack.core.rules;
var entry = path.join(__dirname, './src/index.js');
const sourcePath = path.join(__dirname, './src');
const outputPath = path.join(__dirname, './dist');

module.exports = {
  entry,
  output: {
    path: outputPath,
    filename: 'MyWebApp.js',
  },
  module: {
    rules: [
        { test: /\.html$/, loader: 'html-loader' },
    ].concat(vtkRules),
  },
  resolve: {
      fallback: {
         "stream": require.resolve("stream-browserify")
      }
  }
};
1 Like