vite-plugin-node icon indicating copy to clipboard operation
vite-plugin-node copied to clipboard

ReferenceError: fetch is not defined

Open Archsx opened this issue 3 years ago • 3 comments

I've clone the repo, and cd example directory(express),and install packages, and npm run dev, when I try to entry http://localhost:3699/ip, I got error:

ReferenceError: fetch is not defined

Archsx avatar Jul 13 '22 12:07 Archsx

Try running it with Node >= 18. Global fetch was introduced in Node 18.

kasbah avatar Jul 17 '22 12:07 kasbah

Try running it with Node >= 18. Global fetch was introduced in Node 18.I

I've updated Node to v18.6 but still get the error, maybe the example is just provide some idea about how to use the plugin , not runnable

Archsx avatar Jul 18 '22 16:07 Archsx

I think they should be runnable but I can't run the express example either (getting a different error).

Have you tried the npm run dev-flag script? That seems like it's trying to address the lack of fetch. A workaround could also be to install node-fetch and import it in the example.

kasbah avatar Jul 18 '22 18:07 kasbah

@kasbah what error did you get ? the express example works fine for me under node 18

axe-me avatar Jan 12 '23 03:01 axe-me