Next.js ReferenceError: ReadableStream is not defined

I have this error with my next.js container :

Next.js ReferenceError: ReadableStream is not defined

ReferenceError: ReadableStream is not defined
at Object.<anonymous> (/home/node/app/node_modules/undici/lib/web/fetch/response.js:542:3)
at Module._compile (node:internal/modules/cjs/loader:1196:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
at Module.load (node:internal/modules/cjs/loader:1074:32)
at Function.Module._load (node:internal/modules/cjs/loader:909:12)
at Module.require (node:internal/modules/cjs/loader:1098:19)
at require (node:internal/modules/cjs/helpers:108:18)
at Object.<anonymous> (/home/node/app/node_modules/undici/lib/web/fetch/index.js:11:5)
at Module._compile (node:internal/modules/cjs/loader:1196:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
at Module.load (node:internal/modules/cjs/loader:1074:32)
at Function.Module._load (node:internal/modules/cjs/loader:909:12)
at Module.require (node:internal/modules/cjs/loader:1098:19)
at require (node:internal/modules/cjs/helpers:108:18)
at Object.<anonymous> (/home/node/app/node_modules/undici/index.js:106:19)
at Module._compile (node:internal/modules/cjs/loader:1196:14)

Someone could help me ?

Thank you !

ERROR TypeError: Cannot read properties of undefined (reading ‘setOnModelChange’) at NgxCurrencyDirective.registerOnChange

On click of browser back button, I am navigation to a particular page using route events NavigationStart and NavigationEnd. Expectation is on click of browser back it should navigate to websites homepage but instead screen got stuck and in console below error is printed.
Other places code is working fine but in 1 page i am getting below error, not able to debug the source of it.

ERROR
TypeError: Cannot read properties of undefined (reading 'setOnModelChange')
 at NgxCurrencyDirective.registerOnChange (main.js:179085:24)
 at cleanUpControl (main.js:117684:23)
 at FormGroupDirective.removeControl (main.js:119752:5)
 at FormControlName.ngOnDestroy (main.js:120367:26)
 at executeOnDestroys (main.js:87499:20)
 at cleanUpView (main.js:87411:5)
 at destroyViewTree (main.js:87252:9)
 at destroyLView (main.js:87388:5)
 at ViewRef$1.destroy (main.js:92638:5)
 at ComponentRef.destroy (main.js:94492:19)

Error Screenshot

Wrap TAGS around STRINGS – PURE JS

I need to change the font of all digits in the page.

I thought about using insertBefore() and so on – but then I realized it can’t be used with strings.

What I currently have:

  1. An array with all the text in the page.

  2. An array with all digits.

  3. An array with all digits replaced with the replace() function (A failed attempt).

I also tried to create a for loop that would loop over all words in the array and assign them an element created with a variable – but apparently they can’t be accessed.

How could I wrap all items of the 'string' array with a span or any other tag?

Thank you very much!

let allText = document.querySelector('body').textContent;
console.log(allText);

let digits = allText.match(/d/gi);
console.log(digits);

let rep = allText.replace(/d/gi, "AA");
console.log(rep);
document.body.textContent = rep;
<!DOCTYPE html>
<html lang="en">
<head>
    <style>
        body {
            text-align: center;

            font-size: 40px;
        }
    </style>
</head>
<body>
    <p>
        sdfjsdf
        (1): sdfdsdfs --
        (1): sdfdsdfs --
        (2) sdfsdf --
        (3): sdfsdfs --
        sdfdsfsdf --
    </p>

    <script src="a.js"></script>
</body>
</html>

React Component Re-Rendering everytime

I am building a transport web app of my University as a Project. I have this “BussPass” component which is belo:-

import React, { useEffect, useState, useCallback, useMemo } from 'react';
import Header from '../components/header';
import Footer from '../components/footer';
import { FaAddressCard, FaRupeeSign } from "react-icons/fa";
import PU3 from "../assests/PU3.png";
import NAAC from "../assests/NAAC.png";
import My from "../assests/My.jpg";
import { MdDownload } from "react-icons/md";
import { FaMoneyCheckDollar } from "react-icons/fa6";
import axios from 'axios';
import { usePDF } from 'react-to-pdf';
import "../index.css";

const BusPass = React.memo(() => {
    console.log("BusPass Rendered");

    const user_id = sessionStorage.getItem("user_id");
    const [userData, setUserData] = useState([]);
    const { toPDF, targetRef } = usePDF({ filename: `${user_id}_BusPass.pdf` });

    const getUserInfo = useCallback(async () => {
        if (!user_id) return;

        console.log("Fetching Data");

        try {
            const response = await axios.post("https://putms.onrender.com/getUserInfo", { user_id });
            setUserData(response.data);
        } catch (error) {
            console.error('Error fetching user data:', error);
        }
    }, [user_id]);

    useEffect(() => {
        getUserInfo();
    }, [getUserInfo]);

    const feesPaid = useMemo(() => userData.Bus_Fees_Paid === "Yes", [userData.Bus_Fees_Paid]);

    const openRazorpay = useCallback(() => {
        const options = {
            key: "rzp_test_CXhrGKDYeZO527",
            one_click_checkout: true,
            amount: 22000 * 100,
            name: "Parul University Transport Department",
            order_id: "",
            show_coupons: true,
            callback_url: "https://eneqd3r9zrjok.x.pipedream.net/",
            handler: (response) => {
                axios.post("https://putms.onrender.com/payment", { response, user_id });
            }
        };
        const rzp1 = new window.Razorpay(options);
        rzp1.open();
    }, [user_id]);

    return (
        <>
            <Header />
            <div className='w-full h-[30rem] flex px-2 bg-slate-200'>
                <div className='w-2/3 m-3 bg-slate-100 p-3 cursor-pointer shadow-lg' ref={targetRef}>
                    <div className='flex space-x-2 text-center items-center text-blue-500'>
                        <FaAddressCard className='text-3xl mb-2' />
                        <h4 className='text-center font-semibold'>BUS PASS</h4>
                    </div>
                    <div className='h-[0.1rem] bg-slate-200 w-[100%]'></div>
                    <div className='border border-black h-[22rem] my-3 hover:bg-slate-50'>
                        <div className='h-[5.5rem] flex justify-between py-2 px-4 bg-green-600'>
                            <img src={NAAC} alt="Naac" className='w-1/3 h-full p-1' />
                            <img src={PU3} alt="PuLogo" className='w-1/3 h-full' />
                    .
.
.
And so on...

But while I was checking the performance of my app, I noticed that everytime I go between different routes and come back to this route, it is getting re rendered which should not be happening. I have tried everything I knew to fix it but it didnt help. I even tried ChatGPT to solve but that too was not helping. Can anyone point out where exactly is my mistake and why is my component re rendering each time?

Compilation issue due to .svg file

Facing following issue while compiling.
Previously it was working fine, no code chnages has been made.

Failed to compile.
./src/assets/app/svgs/bottombar.svg (./node_modules/@svgr/webpack/lib?-svgo,+ref!./src/assets/app/svgs/bottombar.svg)
Error: [BABEL] unknown: Requires Babel “^7.16.0”, but was loaded with “7.2.2”. If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn’t mention “@babel/core” or “babel-core” to see what is calling Babel. (While processing: “programmatic item$2”)

Tried installing npm multiple times but unable to understand the issue.

Mathquill: writing in TextField, the previous first node not removed from DOM

I’m trying to write ‘abc’ into MathQuill’s TextField with initial text ‘xyz’

var MQ = MathQuill.getInterface(2);
var mySpan = document.getElementById('A');
var textField = MQ.TextField(mySpan);
textField.latex('abc');
<link href="https://cdnjs.cloudflare.com/ajax/libs/mathquill/0.10.1-a/mathquill.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathquill/0.10.1-a/mathquill.min.js"></script>
<span id="A">xyz</span>

I was expecting ‘abc’ in the text field.

When I load the page, however, I get ‘xabc’.

Then I put the cursor at the right of ‘x’ then stroke backspace, but can’t delete the first node ‘x’.

Then I click on ‘x’ and get the following error:

Uncaught Error: prayer failed: nodeId is the id of some Node that exists
    at s (mathquill.min.js:10:419)
    at t.seek (mathquill.min.js:10:27378)
    at HTMLSpanElement.<anonymous> (mathquill.min.js:10:27058)
    at HTMLSpanElement.dispatch (jquery.min.js:2:40035)
    at v.handle (jquery.min.js:2:38006)

I think this means that ‘x’ was removed from internal node map, but wasn’t removed from DOM.

The above example uses MathQuill v0.10.1-a, I have tried some older versions and I still see this error.

NPM install fails with depreciated node-sass in ubuntu 22 using node 18 [duplicate]

We are having problems running “npm install” on our project in ubuntu 22.
Need to install app without downgrading node version.

Node version is 18.

Simply removing packages and installing all necessary packages mentioned in other post didn’t work because the package was deprecated.

Node Sass is no longer supported. Please use sass or sass-embedded instead.

https://www.npmjs.com/package/node-sass

But i need to install my old app in ubuntu 22 using deprecated node-sass.

How can create the following column chart at highchart?

I am looking for creating a column chart at highchart as the following picture:
enter image description here. In this picture, each column has a linear gradient background color and a start and end value is defined for each column.

The values between start and end of each column, and linear gradient of each column is most important to impelement.

Try catching an async function doesn’t work as expected

I’ve a simple piece of code below:

const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const a = async () => {
  await sleep(100);
  throw new Error('I am an error');
};

const b = async () => {
  return [1, 2, 4].reduce(async (accP, q) => {
    const e = await a(q);
    return [...await accP, { value: q }];
  }, Promise.resolve([]));
};

const main = async () => {
  try {
    return await b();
  } catch (x) {
    console.log('Error');
  }
};

main()
  .then(x => console.log(x))
  .catch(x => console.error(x));

When I execute it, I get:

node asynctest.js
/Users/cgv/asynctest.js:5
  throw new Error('I am an error');
        ^

Error: I am an error
    at a (/Users/cgv/asynctest.js:5:9)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:538:9)
    at process.processTimers (node:internal/timers:512:7)
    at async /Users/cgv/asynctest.js:10:15

My question: Why doesn’t main catch the error thrown by a? How do catch the error in the function that calls reduce without try catching inside the reduce?

How can I translate the JS code into C Sharp code?

I want to add the script below to Animation’s event since it is written in JS. Could anyone help me out to translate (convert) this script into C Sharp?

#pragma strict
var theball:GameObject;

function ThrowBall()
{
    var ballscript:BallScript = theball.GetComponent("BallScript");
    ballscript.ReleaseMe();
}

I tried to import the *.js file since Unity does not support JavaScript anymore.

What are the ways of Accessing attributes of images “ inside ng-image-slider (specifically `onerror` to show default src if img src not found)

I am using an <ng-image-slider> inside angular component to display sliding images. If the source of the image is not available then I want my slider to show default image (with taken into consideration that default image is definitely present). How to do it ?

I have seen to handle such issues we use onerror event for <img> tag. so it would be (error) event handler in angular but how can I do that for an image inside ng-image-slider ?

Here’s the plugin for <ng-image-slider>:
[1]: https://github.com/sanjayV/ng-image-slider

OnclientClick and OnClick is not working at the same time in ?

<form id="form1" runat="server" method="post" class="needs-validation" novalidate="">
    <div class="form-group">
        <label for="txtEmail">Email</label>
        <asp:TextBox runat="server" ID="txtEmail" TextMode="Email" CssClass="form-control" TabIndex="1" ValidateRequestMode="Enabled" autofocus="autofocus" />
        <div class="invalid-feedback">
            Please fill in your email
        </div>
    </div>
    <div class="form-group">
        <asp:Button runat="server" ID="btnSubmit" ClientIDMode="Static" OnClientClick="return startTimer();"  CssClass="btn btn-primary btn-lg btn-block"   UseSubmitBehavior="false"  OnClick="btnSubmit_Click"  Text="Submit" />
        <%--<asp:LinkButton ID="btnSubmit" type="submit" runat="server" ClientIDMode="Static" OnClick="btnSubmit_Click"  CssClass="btn btn-primary btn-lg btn-block" TabIndex="2" Text="Submit" />--%>
    </div>
    <div class="form-group">
        <asp:Label ID="lblTimer" runat="server" ClientIDMode="Static" CssClass="text-dark text-small"></asp:Label>
    </div>
</form>

This is my code,
in the ASP button, I put the onClick() and OnClientClick() at the same time I need to work.
But it could not work.
below I provided the JavaScript function and also my code-behind function.

function startTimer() {
    startMinutes = 1; // Set the desired countdown time
    time = startMinutes * 60;
    btnSubmit.prop('disabled', true);
    btnSubmit.val('Resend');
    timerElement.style.display = 'block';

    if (!interval) {
        interval = setInterval(updateTimerCountdown, 1000);
    }

    return true; // Ensure postback happens
}
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Timer", "alert('button clicked!');", true);
        }

What I Tried:

  1. JavaScript Function (startTimer): You wrote a JavaScript function that starts a timer and disables the button, expecting this to execute before the form submits.
  2. ASP Button with OnClientClick and OnClick: You assigned OnClientClick to call the JavaScript function and OnClick to handle the server-side logic.

What I Expected:
I expected that when the button is clicked:
The

  1. The startTimer JavaScript function would run, disabling the button and starting the timer.
  2. The form would submit after the JavaScript function executes, triggering the server-side btnSubmit_Click event handler.
  3. The alert “button clicked!” would display, confirming the server-side code ran.

What Happened:

  1. Only the client-side JavaScript or the server-side code is executed, not both. The form submission might have been interrupted or the JavaScript might have prevented the postback from happening, leading to either:
  2. The timer starts, but the server-side event (btnSubmit_Click) is not triggered.
  3. The server-side event is being triggered, but the JavaScript not executing as expected.

not able to scroll two elements simultaneously

in reactjs, I have a function that scrolls elements when given a useRef:

 ref.current?.scrollIntoView({
      behavior: "smooth",
      block: "nearest",
      inline: "center",
    });

When this function is called on multiple elements at once, only the one that is called first will actually scroll.

So is it just not possible to scroll multiple elements at once?

If it is possible, what am I do wrong?