instascan icon indicating copy to clipboard operation
instascan copied to clipboard

Problem using npm and webpack

Open Josema opened this issue 6 years ago • 3 comments

When building with webpack I have this issue:

Just this line in my code: import Instascan from 'instascan'

ERROR in ./node_modules/instascan/src/zxing.js
Module not found: Error: Can't resolve 'fs' in '/Users/enzo/Copy/projects/elevenyellow/coinfy/node_modules/instascan/src'
resolve 'fs' in '/Users/enzo/Copy/projects/elevenyellow/coinfy/node_modules/instascan/src'
  Parsed request is a module
  using description file: /Users/enzo/Copy/projects/elevenyellow/coinfy/node_modules/instascan/package.json (relative path: ./src)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Users/enzo/Copy/projects/elevenyellow/coinfy/node_modules/instascan/package.json (relative path: ./src)
    resolve as module

This is the setup I'm using: https://github.com/Josema/preact-webpack-hmr

Josema avatar Jan 05 '18 11:01 Josema

Hi. Did you solve it?

labregowski avatar Jan 09 '18 00:01 labregowski

Adding the following to webpack.config "fixes the issue",

node: { fs: "empty" }

Found here: https://github.com/webpack-contrib/css-loader/issues/447

Gavsum avatar Jan 15 '18 18:01 Gavsum

For Webpack 5, use :

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

https://webpack.js.org/migrate/5/

firestar300 avatar Sep 22 '22 08:09 firestar300