Upgrading to vite 3.1.4 - Module path has been externalized for browser in Chrome
See original GitHub issueDescribe the bug
In a project I am currently using vite 2.9.15 and everything is working fine. When i upgraded to vite 3.1.4, I now get the following warning in Chrome:
browser-external:crypto:9 Module "crypto" has been externalized for browser compatibility. Cannot access "crypto.randomBytes" in client code.
It seems to be coming from importing bcrypt in a file but why is it throwing this warning after upgrading to the new vite version.
I have double checked this to make sure its the vite version causing issues by creating a new branch.
Any advice for what you think might be happening is appreciated!
Reproduction
Install the latest version of vite and import bcrypt
System Info
System:
OS: Windows 10 10.0.19044
CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
Memory: 13.44 GB / 31.92 GB
Binaries:
Node: 14.20.0 - C:\Program Files\nodejs\node.EXE
npm: 8.5.4 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (105.0.1343.50)
Internet Explorer: 11.0.19041.1566
npmPackages:
@vitejs/plugin-vue: ^2.3.4 => 2.3.4
vite: ^3.1.4 => 3.1.4
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Upgrading to vite 3.1.4 - Module path has been externalized ...
When i upgraded to vite 3.1.4, I now get the following warning in Chrome: browser-external:crypto:9 Module "crypto" has been externalized ...
Read more >Module "path" has been externalized for browser compatibility ...
I am having this issue in my app since upgrading to Vite 3. I am still having the issue on v3.0.2. The issue...
Read more >Module "path" has been externalized for browser compatibility
I am using Vite for some front end development, and when I used an external library which is using the "path" library, it...
Read more >module "path" has been externalized for browser compatibility. - You ...
Problem I am using Vite for some front end development, and when I used an external library which is using the "path" library,...
Read more >How can i use Buffer, process in Vite app? - Stack Overflow
Buffer = Buffer; window.process = process;. ` But i still get some error ex: "Module "process" has been externalized for browser compatibility.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, I would recommend that.
Ah sorry about the confusion about bcrypt vs bcryptjs 😬. Thank you for that explanation, do you have a recommendation as to what I could to to resolve the warning? Would you recommend a different node package instead which doesnt “try import and test if exist” ?