farm-fe / farm

Extremely fast Vite-compatible web build tool written in Rust
https://farmfe.org
MIT License
4.51k stars 154 forks source link

when use jsonwebtoken dependence,The Buffer was not found #1196

Open baixjian opened 3 months ago

baixjian commented 3 months ago

Steps to reproduce

Uncaught TypeError: Cannot read properties of undefined (reading 'from') at node_modules/.pnpm/safe-buffer@5.2.1/node_modules/safe-buffer/index.js (index_0607.js:977:16) at ModuleSystem.require ((index):881:13) at node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/sign-stream.js (index_0607.js:472:18) at ModuleSystem.require ((index):881:13) at node_modules/.pnpm/jws@3.2.2/node_modules/jws/index.js (index_0607.js:395:22) at ModuleSystem.require ((index):881:13) at node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/decode.js (index_1571.js:971:15) at ModuleSystem.require ((index):881:13) at node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/index.js (index_1571.js:1000:17) at ModuleSystem.require ((index):881:13)

What is expected?

-

What is actually happening?

-

System Info

-

Any additional comments?

No response

wre232114 commented 3 months ago

jsonwebtoken can not be used in browser, it should be used only in NodeJs. You should use alternative tools like https://www.npmjs.com/package/jwt-decode when targeting browser