I am trying to implement node-fetch with a react app and Webpack setup. But on using the node-fetch. I am getting tons of errors.
ERROR in node:buffer
Module build failed: UnhandledSchemeError: Reading from "node:buffer" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:832:25
at Hook.eval [as callAsync] (eval at create (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Object.processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:829:8)
at processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:220:11)
at iteratePitchingLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:171:10)
at runLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:398:2)
at NormalModule._doBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:819:3)
at NormalModule.build (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:963:15)
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/Compilation.js:1371:12
at NormalModule.needBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:1256:26)
ERROR in node:fs
Module build failed: UnhandledSchemeError: Reading from "node:fs" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:832:25
at Hook.eval [as callAsync] (eval at create (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Object.processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:829:8)
at processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:220:11)
at iteratePitchingLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:171:10)
at runLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:398:2)
at NormalModule._doBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:819:3)
at NormalModule.build (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:963:15)
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/Compilation.js:1371:12
at NormalModule.needBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:1256:26)
ERROR in node:https
Module build failed: UnhandledSchemeError: Reading from "node:https" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:832:25
at Hook.eval [as callAsync] (eval at create (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Object.processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:829:8)
at processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:220:11)
at iteratePitchingLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:171:10)
at runLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:398:2)
at NormalModule._doBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:819:3)
at NormalModule.build (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:963:15)
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/Compilation.js:1371:12
at NormalModule.needBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:1256:26)
ERROR in node:http
Module build failed: UnhandledSchemeError: Reading from "node:http" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:832:25
at Hook.eval [as callAsync] (eval at create (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/tapable/lib/Hook.js:18:14)
at Object.processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:829:8)
at processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:220:11)
at iteratePitchingLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:171:10)
at runLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:398:2)
at NormalModule._doBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:819:3)
at NormalModule.build (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:963:15)
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/Compilation.js:1371:12
ERROR in node:net
Module build failed: UnhandledSchemeError: Reading from "node:net" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:832:25
at Hook.eval [as callAsync] (eval at create (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Object.processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:829:8)
at processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:220:11)
at iteratePitchingLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:171:10)
at runLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:398:2)
at NormalModule._doBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:819:3)
at NormalModule.build (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:963:15)
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/Compilation.js:1371:12
at NormalModule.needBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:1256:26)
ERROR in node:path
Module build failed: UnhandledSchemeError: Reading from "node:path" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:832:25
at Hook.eval [as callAsync] (eval at create (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Object.processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:829:8)
at processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:220:11)
at iteratePitchingLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:171:10)
at runLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:398:2)
at NormalModule._doBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:819:3)
at NormalModule.build (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:963:15)
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/Compilation.js:1371:12
at NormalModule.needBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:1256:26)
ERROR in node:process
Module build failed: UnhandledSchemeError: Reading from "node:process" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:832:25
at Hook.eval [as callAsync] (eval at create (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Object.processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:829:8)
at processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:220:11)
at iteratePitchingLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:171:10)
at runLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:398:2)
at NormalModule._doBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:819:3)
at NormalModule.build (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:963:15)
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/Compilation.js:1371:12
at NormalModule.needBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:1256:26)
ERROR in node:stream/web
Module build failed: UnhandledSchemeError: Reading from "node:stream/web" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:832:25
at Hook.eval [as callAsync] (eval at create (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Object.processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:829:8)
at processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:220:11)
at iteratePitchingLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:171:10)
at runLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:398:2)
at NormalModule._doBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:819:3)
at NormalModule.build (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:963:15)
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/Compilation.js:1371:12
at NormalModule.needBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:1256:26)
ERROR in node:stream
Module build failed: UnhandledSchemeError: Reading from "node:stream" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:832:25
at Hook.eval [as callAsync] (eval at create (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Object.processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:829:8)
at processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:220:11)
at iteratePitchingLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:171:10)
at runLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:398:2)
at NormalModule._doBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:819:3)
at NormalModule.build (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:963:15)
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/Compilation.js:1371:12
at NormalModule.needBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:1256:26)
ERROR in node:url
Module build failed: UnhandledSchemeError: Reading from "node:url" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:832:25
at Hook.eval [as callAsync] (eval at create (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Object.processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:829:8)
at processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:220:11)
at iteratePitchingLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:171:10)
at runLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:398:2)
at NormalModule._doBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:819:3)
at NormalModule.build (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:963:15)
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/Compilation.js:1371:12
at NormalModule.needBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:1256:26)
ERROR in node:util
Module build failed: UnhandledSchemeError: Reading from "node:util" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:832:25
at Hook.eval [as callAsync] (eval at create (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Object.processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:829:8)
at processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:220:11)
at iteratePitchingLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:171:10)
at runLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:398:2)
at NormalModule._doBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:819:3)
at NormalModule.build (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:963:15)
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/Compilation.js:1371:12
at NormalModule.needBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:1256:26)
ERROR in node:zlib
Module build failed: UnhandledSchemeError: Reading from "node:zlib" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:832:25
at Hook.eval [as callAsync] (eval at create (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Object.processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:829:8)
at processResource (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:220:11)
at iteratePitchingLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:171:10)
at runLoaders (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/loader-runner/lib/LoaderRunner.js:398:2)
at NormalModule._doBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:819:3)
at NormalModule.build (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:963:15)
at /mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/Compilation.js:1371:12
at NormalModule.needBuild (/mnt/c/Users/nageshkatna/Desktop/frontend/node_modules/webpack/lib/NormalModule.js:1256:26)
This is how my webpack config looks like
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
entry: path.resolve(__dirname, './src/index.tsx'),
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
module: {
rules: [
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
},
],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
{
test: /\.(?:ico|gif|png|jpg|jpeg)$/i,
type: 'asset/resource',
},
{
test: /\.(woff(2)?|eot|ttf|otf|svg|)$/,
type: 'asset/inline',
},
],
},
devServer: {
hot: true,
open: true,
},
output: {
path: path.resolve(__dirname, '..', './build'),
filename: 'bundle.js',
},
mode: 'development',
devtool: 'cheap-module-source-map',
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, './src/index.html'),
}),
new CopyPlugin({
patterns: [{ from: 'src', to: 'build' }],
}),
],
};
All I am trying to use is to use it here
import fetch from 'node-fetch';
const login = (body) => {
const env = process.env;
fetch(`${env.AUTH_API_BASE_URL}/user/authentication`, {
method: 'post',
body: JSON.stringify(body),
headers: { 'Content-type': 'application/json' },
})
.then((response) => {
console.log(response);
})
.catch((err) => {
const res = {
message: err.message,
status: err.status,
};
return res;
});
};
export default login;
Am I missing a configuration on Webpack? I tried installing packages like node-polyfill-webpack-plugin
and node-libs-browser
but didn't work or maybe I was not able to configure them properly.