Upgrading to vite 3.1.4 - Module path has been externalized for browser in Chrome

See original GitHub issue

Describe 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. image 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

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sapphi-redcommented, Oct 2, 2022

Yes, I would recommend that.

0reactions
rezelutecommented, Oct 1, 2022

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” ?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found