Why does ‘node .’ always throw an error when I type it in cmd?

I just started with my first discord bot and I am really stuck with this problem. Everytime I write ‘node .’ it gives an error stating this ‘throw new TypeError(‘CLIENT_MISSING_INTENTS’);’can anybody tell me what I need to fix?

That’s all the code I got:

const Discord = require('discord.js');
const bot = new Discord.Client();
const token = 'myToken';

bot.on('ready', () =>{
    console.log('This bot is online!');


picture of the error

Cannot find module ‘node:events’

when i started the code i’ve got this error

Error: Cannot find module 'node:events'
Require stack:
- C:RAGEMPserver-filesnode_modulesdiscord.jssrcclientBaseClient.js
- C:RAGEMPserver-filesnode_modulesdiscord.jssrcindex.js
- C:RAGEMPserver-filespackagesDominoRPdiscordindex.js
- C:RAGEMPserver-filespackagesDominoRPindex.js
- C:RAGEMPserver-filesbinloader.mjs
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:893:15)
    at Function.Module._load (internal/modules/cjs/loader.js:743:27)
    at Module.require (internal/modules/cjs/loader.js:965:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (C:RAGEMPserver-filesnode_modulesdiscord.jssrcclientBaseClient.js:3:22)
    at Module._compile (internal/modules/cjs/loader.js:1076:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:941:32)
    at Function.Module._load (internal/modules/cjs/loader.js:782:14)
    at Module.require (internal/modules/cjs/loader.js:965:19)

this is my code

const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', async () => {
   console.log('!!! => Discord bot has authenticated successfully...');


i have upgrade to node 16.13 but same thing. Can anyone help me?

How to convert base64 image data to data URL in react native?

I am using react-native-signature-canvas which returns the signature as a base64 image string. I want to send it to the API and before that, I want to convert it to the data URL. Can anyone help me? Also, I don’t want to store the file/image to the local storage..just wanna convert it to the DataUrl and send it to the API.

ASP .NET CORE MVC, html – choose default image if user didn’t choose any

I want the “Choose file” to be optional. That means if user does not click “Choose file”, the default image (/wwwroot/n-image/NoImage.png) is chosen. “Image” is a string property of Article object.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <div class="form-group">
      <label asp-for="Image" class="control-label"></label>
      <br />
      <div class="custom-file">
        <input type="file" asp-for="Image" class="custom-file-input" id="FLFormFIle" />
      <span class="text-danger"></span>
      <br />

    <img id="FormFilePrv" src="" style="border:1px; top:20px;margin-left:120px;" />
    <div class="form-group">
      <br />
      <input type="submit" value="Utwórz artykuł" class="btn btn-primary" />

$(".custom-file-input").on("change", function() {
  var fileName = $(this).val().split("\").pop();
  document.getElementById('FormFilePrv').src = window.URL.createObjectURL(this.files[0])

What is the difference between these two singleton approaches in JS?

The way to solve the singleton pattern in JS (TS actually) is looks like this (the best approach if you ask me):

export default class Singleton {
    private static _instance: Selection

    constructor() {
        if (Selection._instance) {
            return Singleton._instance
        } else {
            Singleton._instance = this

And then:

import Singleton from './Singleton.ts'

const singleton_1 = new Singleton()
const singleton_2 = new Singleton()

singleton_1 === singleton_2 // true

But in this scenario I have to create new variables every time I need that class.

I can achieve exactly the same the easier way:

class Singleton {
    constructor() {
        // some logic

export default new Singleton()
import Singleton from './Singleton.ts'

const wut = Singleton.field
Singleton.method('do something')

Am I getting something wrong or the first approach is a little bit excessive and complicated and the second one just do the same thing in more obvious way?

I understand that if I have static fields in my class, I couldn’t use it that way, but cases when you really need static fields are rare.

Are there some different configurations for running java script in java spring boot

I wanted to do my input text box read-only when I clicked a link and get navigated to the same page. When I tried to run the code in my IDE, it was not running efficiently. It wasn’t making the text-boxes read-only. But when I ran the same code in an simple Html file it did run perfectly. Please help me in solving my issue. Below is my code of my jsp page.

<!DOCTYPE html>

    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

    <title>Mole Calculator | Chemistry Calculator</title>



    <nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-black">

        <div class="container-fluid">
            <a class="navbar-brand" href="#">
                    <b>Chemistry Calculator</b>

            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>

            <div class="collapse navbar-collapse" id="navbarSupportedContent">

                <ul class="navbar-nav  text-uppercase">

                    <li class="nav-item"><a class="nav-link active" aria-current="page" href="/Chemistry-Calculator/">Home</a></li>

                    <li class="nav-item"><a class="nav-link active" aria-current="page" href="/Chemistry-Calculator/about">About</a></li>



    <div class="container" style="padding-top: 5%;">

        <div class="card px-4 py-5" style="width: 650px;">
            <div class="card-block">

                <form action="/Chemistry-Calculator/Number-Of-Moles">

                    <div class="mb-3">
                        <label for="givenMass" class="form-label">Given Mass of
                            Substance</label> <input type="text" class="form-control" id="givenMass" aria-describedby="emailHelp" name="givenMass" value="${givenMass}" style="width: 600px">
                    <div class="mb-3">
                        <label for="molarMass" class="form-label">Molar Mass</label> <input type="text" class="form-control" id="molarMass" name="molarMass" value="${molarMass}" style="width: 600px">

                    <div class="mb-3">
                        <label for="moles" class="form-label">Moles</label> <input type="text" class="form-control" id="moles" name="moles" value="${moles}" style="width: 600px">

                    <input class="btn btn-outline-success" type="submit" value="Calculate">

                    <div class="btn-group">
                        <button type="button" class="btn btn-success dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">Choose
                            what to calculate</button>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item" onclick="readonlyForMoles()" href="#">Calculate Moles</a></li>
                            <li><a class="dropdown-item" onclick="readonlyForMolarMass()" href="#">Calculate Molar
                            <li><a class="dropdown-item" onclick="readonlyForGivenMass()" href="#">Calculate Given


    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

        function readonlyForGivenMass() {
            document.getElementById("givenMass").readOnly = true;
            document.getElementById("molarMass").readOnly = false;
            document.getElementById("moles").readOnly = false;


        function readonlyForMolarMass() {
            document.getElementById("givenMass").readOnly = false;
            document.getElementById("molarMass").readOnly = true;
            document.getElementById("moles").readOnly = false;

        function readonlyForMoles() {
            document.getElementById("givenMass").readOnly = false;
            document.getElementById("molarMass").readOnly = false;
            document.getElementById("moles").readOnly = true;



How to open specific Bootstrap tab by clicking on a link

I’m trying to add a Bootstrap tab panel goes like this:

<ul class="nav nav-tabs" role="tablist">
    <li class="nav-item">
        <a class="nav-link active" data-toggle="tab" href="#tabs-1" role="tab">First Panel</a>
    <li class="nav-item">
        <a class="nav-link" data-toggle="tab" href="#tabs-2" role="tab">Second Panel</a>
    <li class="nav-item">
        <a class="nav-link" data-toggle="tab" href="#tabs-3" role="tab">Third Panel</a>
</ul><!-- Tab panes -->
<div class="tab-content">
    <div class="tab-pane active" id="tabs-1" role="tabpanel">
        <p>First Panel</p>
    <div class="tab-pane" id="tabs-2" role="tabpanel">
        <p>Second Panel</p>
    <div class="tab-pane" id="tabs-3" role="tabpanel">
        <p>Third Panel</p>

Now I need to give link to users to see the panes like this:


But this won’t work because the tab-pane with an id of tabs-2 does not have the .active class.

However, if I try loading https://sitename.com/page#tabs-1 The page properly redirects me to tab-pane with an id of tabs-1 (because it has .active class by default)

So how can I redirect users to different tab panes correctly?

Dealing with floating point precision in power function

I am having trouble coming up with a class to deal with floating point precision, specifically the pow program which generates the nth power of a number (the base or exponent can be negative or exist as a decimal). I have viewed others’ explanations and copied a lot of code, however the function still generates results with floating point errors:

class Core{
    to_fraction(decimal, tolerance = 0){
        var skipped = false; 
        if (isNaN(decimal) || isNaN(tolerance)) return; 
        for (var denominator = 1; (decimal * denominator) % 1 != 0; denominator++) if (Math.abs(Math.round(decimal * denominator) / denominator - decimal) < tolerance){skipped = true; break}; 
        if (skipped) return {numerator: Math.round(decimal * denominator), denominator: denominator, difference: Math.round(decimal * denominator) / denominator - decimal};
        if (!skipped) return {numerator: decimal * denominator, denominator: denominator};

        if (a.toString().split(".").length == 1) return 0; 
        return a.toString().split(".")[1].length; 

class Correct{
    cf(a, b){
        return Math.pow(10, Math.max(core.dplaces(a), core.dplaces(b))); 

    divide(a, b){
        var _cf = this.cf(a, b); 
        return (a * _cf) / (b * _cf); 

    multiply(a, b){
        var _cf = this.cf(a, b); 
        return (a * _cf) * (b * _cf) / (_cf * _cf); 

    subtract(a, b){
        var _cf = this.cf(a, b); 
        return ((a * _cf) - (b * _cf)) / _cf; 

    add(a, b){
        var _cf = this.cf(a, b); 
        return ((a * _cf) + (b * _cf)) / _cf; 

    pow(a, b){
        var fraction = core.to_fraction(b); 
        for (var count = 0, result = 1; count < fraction.numerator; count++) result = this.multiply(result, a); 
        result = result ** (1 / fraction.denominator); // Da problems starts here

        return result; 

        if (number % 1 || !(Math.abs(number) >= 0)) return NaN; 
        if (number > 170) return Infinity;
        var result = 1;
        while (number > 1) result *= number--;
        return result;

const core = new Core(), correct = new Correct(); 

console.log(correct.pow(7.154840569262962e+21, 1 / 5));

It seems that the problem starts on the second filled line of the pow function within the Correct class, however I cannot find or think of a method to avoid or change the stuff on that line.

This is extremely frustrating and rather unfortunate. Please suggest an alternative method (preferably in JavaScript or Node js) to achieve such effects or modify that line. Thank you!

OpenWeathermap country codes code proplem “city not found”

im writing a code for a weather journal app the thing is when i pass to fetch method the url of the site of openweathermap.com with the zip code and country code way it only accepts the country code as US it never accepts anyother country i tried so many but it never accepts any of those it only returns the data object of forecast to US anyother country it just show the message city not found here is my code:

const generate = document.getElementById('generate').addEventListener('click', function(){
    const zip = document.getElementById('zip').value;
    const countryCode = document.getElementById('countryCode').value;

const endPointData = async (zip,countryCode,apiKey) => {
    const res = await fetch(`https://api.openweathermap.org/data/2.5/weather?zip=${zip},${countryCode}&appid=${apiKey}`);

        const data = await res.json();
        // appropriately handles the errors.

const postData = async (url='', data = {}) => {
    const response = await fetch(url,{
        method: 'POST',
        credentials: 'same-origin',
        headers: {
            'Content-Type': 'application/json'
        body: JSON.stringify(data),
        const newData = await response.json();
        return newData;

JQuery DataTable Cell InnerHTML Update Issue

Thanks for opening this question and help me!

I am using JQuery DataTable and want to update the InnerHTML in each cell. The reason is that that:

Original data in each DataTable Cell is plain text and hard to read. For example:

[ { "wikidataid": "Q142" }, { "wikidataid": "Q55" }, { "wikidataid": "Q39" }, { "wikidataid": "Q34" }, { "wikidataid": "Q36" }, { "wikidataid": "Q20" } ]

So, I want to create an unordered list so the data could be show in a formatted way instead of a plain text and override the innerHTML of dataTable cells.

This is the code I wrote:

        var table = $('#queryTable').DataTable();
        var data = table.rows().data();

        //Loop each row
        data.each(function (value, index) {
            //Loop each column
            for(var i=0; i<value.length; i++){
                // only column 2 and 3 are the data we want to format
                if (i != 2 && i != 3){
                var content = JSON.parse(value[i])

                var ul=document.createElement('ul');
                for (var k = 0; k < content.length; ++k) {
                    var li=document.createElement('li');
                    li.setAttribute("class", "list");

                    li.innerHTML = "WikiDataId: " + content[k].wikidataid;   // Use innerHTML to set the text
                    if (content[k].attributes != null) {
                        for (var j = 0; j < content[k].attributes.length; ++j){
                            var ulsub=document.createElement('ul');
                            ulsub.value = content[k].attributes[j].changedtype;
                            var liName=document.createElement('li');
                            liName.innerHTML = content[k].attributes[j].name + ": " + content[k].attributes[j].value;
                // console.log(index);
                // console.log(i);
                // console.log(ul);
                //table.cell(index, i).data(ul.html()).draw();

                table.cell(index, i).node().innerHTML = null;
                table.cell(index, i).node().appendChild(ul);

                console.log(table.cell(index, i).node());

However, after I run the above code, although the data is formatted into unordered list. But the data in the each row’s cells are not updated correctly. For example, the 1st row’s data contains the 3rd rows data, the 2rd row’s data contains the 5th rows data, the 3rd row’s data contains the 6th rows data and etc.

I am not sure if the way I update inner html is correct. Could anyone help here? Thanks so much!

How to know if the user is dropping the file on the defined location?

On this application, the user can drag and drop a file on the specified location. Let say here:

<div id="dropZone" style="width: 200px; height: 100px;"></div>

However, we noticed that no matter where the file is drop, the webpage will process it. Here is an example taken online https://jsfiddle.net/oL2akhtz/. There is a place to drop the file, but no matter where you leave it, it will stay. How to know if the user is droping the file in the right place? Or how do you disable the cursor if the user is not droping the file where it should be?

Are hashes in the names Javascript and CSS files used for integrity checking?

Many websites use hashes in Javacript and CSS file’s name. For example, this page, as of writing, uses a file referred to with URL .../stacks.min.js?v=b0f9a80d741d. Other sites just place a short hash in the file’s name: main.abcd123.js

  • Is this used automated integrity checking? For example, when the browser loads stacks.min.js?v=b0f9a80d741d, does is verify that a hash or digest of this file matches b0f9a....
  • Does this pattern have a name?

Getting ERR_SSL_PROTOCOL Error when trying to send a post request to my Node.js Server in ReactJs

I am creating a DHL API for checking shipment rates. I have uploaded my Node.js Server using putty and it is running correctly when I enter my IP address and port number.

In development, there are no erros or issues and I get back the response and get the rates back from the form I have set up for my users.

but in Production, when I upload my website to Hostinger I get this error ” Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR”

In production, it sends my post request with HTTPS instead of HTTP. And even when I change the HTTPS to HTTP in the browser I get another error saying “Cannot GET /api/dhl”

Here are some images to help make it more clear:

The Errors.

enter image description here

When my website submits the post request with HTTPS instead of HTTP.

enter image description here

When I manually change the URL from HTTPS to HTTP

enter image description here

What am I doing wrong? Why is this happening and how can I fix it?

Here is my code:

const express = require('express');
const port = 3001
app.post('/api/dhl', (req, res) => {

const accountNum = req.body.accountNum

const fromCountriesCode = req.body.fromCountriesCode
const fromCountriesCapital = req.body.fromCountriesCapital
const fromCity = req.body.fromCity
const fromPostalCode = req.body.fromPostalCode

const toCountriesCode = req.body.toCountriesCode
const toCountriesCapital = req.body.toCountriesCapital
const toCity = req.body.toCity
const toPostalCode = req.body.toPostalCode

const weight = parseInt(req.body.weight)
const plannedShippingDate = req.body.date

const len = "5"
const width = "5"
const height = "5"
const isCustomsDeclarable = 'false' 
const unitOfMeasurement = 'metric'



var options = { method: 'POST',
url: 'https://express.api.dhl.com/mydhlapi/rates',
 { 'postman-token': '',
   'cache-control': 'no-cache',
   authorization: 'Basic myauthkey',
   'content-type': 'application/json' },
 { customerDetails: 
    { shipperDetails: 
       { postalCode: fromPostalCode,
         cityName: fromCity,
         countryCode: fromCountriesCode,
         addressLine1: '0' },
       { postalCode: toPostalCode,
         cityName: toCity,
         addressLine1: '0',
         countryCode: toCountriesCode }
   accounts: [ { typeCode: 'shipper', number: 'my account number' } ],
   plannedShippingDateAndTime: '2021-08-25T13:00:00GMT+00:00',//Might need to change later
   unitOfMeasurement: 'metric',
   isCustomsDeclarable: true,
   monetaryAmount: [ { typeCode: 'declaredValue', value: 10, currency: 'BHD' } ],
   requestAllValueAddedServices: false,
   returnStandardProductsOnly: false,
   nextBusinessDay: false,
   packages: [ { weight: weight, dimensions: { length: 5, width: 5, height: 5 } } ] },
json: true };

request(options, function (error, response, body) {
    if (error) throw new Error(error);

//Start the Server
app.listen(port, () => {
  console.log(`Server running at :${port}/`);

My Check-Rates File:
const getRateEstimate = () => {

axios.post('http://MY_IP:3001/api/dhl', {




 }).then(response => {


 }).catch(e => {



How did I get 111 npm downloads already?

So 2 days ago I published my first npm package
A simple library to trim and join audio files.
The weird thing is I already got 111 downloads somehow.
I havent shared this package with anyone
Neither have I documented anything. The readme is literally blank
could this be a mistake??
Edit: This might like look like I am trolling or something, but I assure I am genuinely curious about what’s going on. Please dont downvote this question for no reason.