For libraries, I found a rather nice pattern to allow users to only install node-fetch if they need it:
// package.json{"peerDependencies":{"node-fetch":"*"},"peerDependenciesMeta":{"node-fetch":{"optional":true}}}// Run before you use fetch:if(!globalThis.fetch){Object.assign(globalThis,{fetch:(...args:any[])=>{try{constfetch=require("node-fetch");Object.assign(globalThis,{fetch});returnfetch(...args);}catch(e){console.warn('"\x1b[33m⚠️ package missing to run fetch on the server.\n Please run:\x1b[0m\n\nnpm i node-fetch\n"');Object.assign(globalThis,{fetch:()=>Promise.reject()});returnPromise.reject();}}});}
This way, users get a helpful message if they forget to install node-fetch and you can avoid superfluous dependencies.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
For libraries, I found a rather nice pattern to allow users to only install node-fetch if they need it:
This way, users get a helpful message if they forget to install node-fetch and you can avoid superfluous dependencies.