schmich / instascan

HTML5 QR code scanner using your webcam
https://schmich.github.io/instascan/
MIT License
2.97k stars 864 forks source link

Problem using npm and webpack #121

Open Josema opened 6 years ago

Josema commented 6 years ago

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

labregowski commented 6 years ago

Hi. Did you solve it?

Gavsum commented 6 years ago

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

node: { fs: "empty" }

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

firestar300 commented 2 years ago

For Webpack 5, use :

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

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