not working with react with next js ,
nileshzala005 opened this issue · 3 comments
Using typed-rest-client with react next js
not able to init RestClient
import { IRequestQueryParams } from 'typed-rest-client/Interfaces';
import * as restc from 'typed-rest-client/RestClient';
export class HttpClientWrapper {
init() {
const http = new restc.RestClient('vsts-node-api');
}
}
Getting this error
error - ./node_modules/typed-rest-client/HttpClient.js:134:0
Module not found: Can't resolve 'fs'
Import trace for requested module:
./node_modules/typed-rest-client/RestClient.js
./services/httpClientWrapper.ts
./services/helperService.ts
./pages/_app.tsx
Package.json
{
"name": "exco-web-app",
"version": "4.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"lint": "next lint",
"build": "next build",
"start": "next start"
},
"dependencies": {
"@sentry/nextjs": "^7.15.0",
"next": "12.3.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"typed-rest-client": "^1.8.9"
},
"devDependencies": {
"@types/node": "18.8.3",
"@types/react": "18.0.21",
"@types/react-dom": "18.0.6",
"eslint": "8.25.0",
"eslint-config-next": "12.3.1",
"eslint-plugin-react-hooks": "^4.6.0",
"typescript": "4.8.4"
}
}
Hi @nileshzala005, thanks for reporting! We are working on more prioritized issues at the moment, but will get back to this one soon.
after spending a few hours, able to fix
install net , tls package and update next.config.js as following
const nextConfig = {
swcMinify: true,
reactStrictMode: true,
output: 'standalone',
webpack: (config) => {
config.resolve.fallback = { fs: false }
return config;
}
}
This issue has had no activity in 90 days. Please comment if it is not actually stale