Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue 2 error regarding get-pixels/request/asn1, was: broken dependency from recent updates? #536

Open
lampsbr opened this issue Apr 15, 2024 · 2 comments
Labels
dependencies Pull requests that update a dependency file enhancement help wanted javascript Pull requests that update Javascript code maintenance

Comments

@lampsbr
Copy link

lampsbr commented Apr 15, 2024

Hi!
I run current quagga2 in a vue.js 2 project that gives me the following error message after a recent npm install:

WARNING in ./node_modules/asn1.js/lib/asn1/api.js 21:12-42
Module not found: Error: Can't resolve 'vm' in '/var/www/html/node_modules/asn1.js/lib/asn1'
Did you miss the leading dot in 'resolve.extensions'? Did you mean '[".*",".wasm",".mjs",".js",".jsx",".json",".vue"]' instead of '["*",".wasm",".mjs",".js",".jsx",".json",".vue"]'?

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: { "vm": require.resolve("vm-browserify") }'
        - install 'vm-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "vm": false }

webpack compiled with 1 warning
^C
4250f6a17e25:/var/www/html# npm ls asn1
project /var/www/html
`-- @ericblade/[email protected]
  `-- [email protected]
    `-- [email protected]
      `-- [email protected]
        `-- [email protected]
          `-- [email protected]

I just checked that get-pixels does not have an update currently, so I don't know for sure how can this be fixed.

@ericblade
Copy link
Owner

hmm. There had been some talk on here about someone forking get-pixels to remove the dependency on request, since request is also effectively deprecated, although I haven't heard anything about if anyone actually did that or not.

Quagga does not use the request functionality, so I'd think it would be safe to configure Vue with the resolve.fallback: { vm: false } as it suggests.

I don't use Vue, but I have done work towards upgrading Quagga to use webpack > 4 and have not run into any problems with get-pixels/request/...asn1 so I think this is technically a Vue problem, although I will admit that I find it... distasteful... to continue using things that depend on deprecated systems, I think that it's safe to tell Vue to ignore that issue.

I don't really have time to handle adding more packages to maintain to my plate... but if someone wants to make a new get-pixels that either strips the request functionality out, or replaces it with a native fetch...

Also while doing some quick looking around, there's https://github.com/donmccurdy/ndarray-pixels which may have the same functionality (it's not clear to me if it can take a dataurl directly, as get-pixels can), though it looks like at the very least the inputs differ, so it's not a straight plugin and replace.

I'd much rather depend on something that is seeing updates, unlike get-pixels, which it's last update broke semantic-version, and has had only one commit in 6 years. However, it does look like ndarray-pixels might require native support since it uses sharp in node, which would be a HUGE change for what Quagga can run on.

@ericblade ericblade changed the title broken dependency from recent updates? Vue 2 error regarding get-pixels/request/asn1, was: broken dependency from recent updates? Apr 15, 2024
@ericblade ericblade added enhancement help wanted maintenance dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code labels Apr 16, 2024
@lampsbr
Copy link
Author

lampsbr commented Apr 16, 2024

Thank you for your response! I've just done what the message recommended and it worked:

  • Installed vm-browserify package in project,
  • Put that override line in webpack/mix config file.

My project is running webpack 5.5, I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement help wanted javascript Pull requests that update Javascript code maintenance
Projects
None yet
Development

No branches or pull requests

2 participants