-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Node built-in module functions are getting undefined under vue-cli #3644
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
Comments
Since you can't use native node modules in the browser, those will always be What behaviour did you expect? |
I can use crypto, except for some properties (e.g. scrypt, scryptSync). In the minimal project showed the crypto object. Now I even used other functions from it and pushed to the example repo.
I expected to have all properties/functions present at crypto |
Scrypt is written in native code (C++), not JavaScript. It can not run in the browser. Webpack cannot bundle it with your JavaScript, and a browser can't run it. |
My bad, thank you |
Webpack can be provided with polyfills: https://webpack.js.org/configuration/node/ The specific case of scrypt is a little complicated though. There's a browserify shim that might need some adjustment: https://github.com/crypto-browserify/scrypt Hope this helps someone. |
Version
3.5.1
Reproduction link
https://github.com/FabioOliveira1/minimal
Environment info
Steps to reproduce
npm i
npm run serve
-- Open in browser
-- Open inspector, there will be the logs of crypto as object and the scryptSync as undefined
What is expected?
scryptSync as a function, since it's a built in node module
What is actually happening?
scryptSync is undefined
I am not sure if this is caused by vue cli or by one of its dependencies, but at my searching I found something related here
The text was updated successfully, but these errors were encountered: