MonoRepo: Issue with `npm link` and `regenerator-runtime`: Local Package Linking Causes Errors in Different Scenarios

I’m encountering a peculiar issue when trying to link a local sub-project package (x) in the frontend project of a monorepo using npm link. The problem manifests differently depending on the order of commands I execute. First, I cloned and ran npm install in both repositories. Second, I run yarn build and npm link in the x project. Then, here’s what I’m doing next in the frontend project:

Scenario 1:

  1. I run npm link @monorepoName/x.
  2. Then, I run npm install regenerator-runtime@latest.
  3. Finally, I execute npm run dev:hot.

After these steps, the link to my local x project gets removed, and my frontend project seems to revert to using the x version from the npm repository.

Scenario 2:

  1. First, I run npm install regenerator-runtime@latest.
  2. Then, I execute npm link @monorepoName/x.
  3. Lastly, I run npm run dev:hot.

In this scenario, when I open the project URL in the browser, I get an error: 'Uncaught ReferenceError: regeneratorRuntime is not defined'.

I don’t know why the order of these commands impacts the behavior in such a way. I’m seeking insights into what might be causing these issues and how to resolve them.

Any suggestions on what might be causing these issues or how to properly link a local package while managing dependencies like regenerator-runtime would be greatly appreciated.

Let me know in the comments if you need more information.

I’m encountering a peculiar issue when trying to link a local sub-project package (x) in the frontend project of a monorepo using npm link. The problem manifests differently depending on the order of commands I execute. First, I cloned and ran npm install in both repositories. Second, I run yarn build and npm link in the x project. Then, here’s what I’m doing next in the frontend project:

Scenario 1:

  1. I run npm link @monorepoName/x.
  2. Then, I run npm install regenerator-runtime@latest.
  3. Finally, I execute npm run dev:hot.

After these steps, the link to my local x project gets removed, and my frontend emphasized textproject seems to revert to using the x version from the npm repository.

Scenario 2:

  1. First, I run npm install regenerator-runtime@latest.
  2. Then, I execute npm link @monorepoName/x.
  3. Lastly, I run npm run dev:hot.

In this scenario, when I open the project URL in the browser, I get an error: 'Uncaught ReferenceError: regeneratorRuntime is not defined'.

I don’t know why the order of these commands impacts the behavior in such a way. I’m seeking insights into what might be causing these issues and how to resolve them.

Am I missing anything in setting up such interconnected projects?
Let me know in the comments if you need more information.

New to Tailwind CSS, how do I get my Tailwind to display to my simple webpage?

I’m new to Tailwind CSS (first project) and I feel like I’m missing a basic step in getting my Tailwind to work properly.

I have my Project Folder Structure:

Lesson01

  • build (folder)

     css (folder)
      
        style.css
      
        index.html
  • src

      input.css

      tailwind.config.js

I’m trying to make an emerald colored div box with some different classes applied for shadows and making the object a full circle. Nothing too crazy yet.

index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="./css/style.css">
</head>

<body class="min-h-screen grid place-content-center">
  <div class="bg-emerald-500 w-52 h-52 rounded-full shadow-2xl"></div>
</body>
</html>

tailwind.config.js

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ['./build/*.html'],
  theme: {
    extend: {},
  },
  plugins: [],
}

style.css is the output of the generated base Tailwind css file.

input.css contains the initial layers for Tailwind CSS

@tailwind base;
@tailwind components;
@tailwind utilities;

I’m new to Tailwind but I would love to learn and apply it for my home projects that I’m experimenting with. Any advice would be much appreciated!

I tried running

npx tailwindcss -i ./src/input.css -o ./build/css/style.css --watch

in the terminal to update the style.css file using the input.css file.

However, I didn’t see any expected results. I did get hit with this:

Rebuilding...

warn - No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.
warn - https://tailwindcss.com/docs/content-configuration

Done in 58ms.

So the issues I’m hitting are for sure due to my noviceness with Tailwind haha.

Any help would be appreciated and I’m new to posting on StackOverflow as well!

Java/Spring Boot 415 Unsupported Media Type Error with POST request

“I wrote a POST method that saves data from the form.html to the database. It correctly saves the data in the database, but when I run my endpoint in the browser (I tried Chrome, Opera, Edge), I still encounter the 415 issue. After clicking on the ‘Continue’ button, I only see a 415 error. In Postman, I receive a status 200 OK. I tried Chrome DevTools, and I get the same result: status 200 and redirection to the appropriate endpoint after all. Do you know where problem can be ?

Here is the related javascript code.
function sendData() {
  const form = document.getElementById('form');
  const insuranceSelect = form.querySelector('#insurance');
  const selectedInsurance = insuranceSelect.options[insuranceSelect.selectedIndex].value;

  const data = {
    "firstName": form.querySelector('#firstName').value,
    "lastName": form.querySelector('#lastName').value,
    "email": form.querySelector('#email').value,
    "password": form.querySelector('#password').value,
    "birthDate": form.querySelector('#birthDate').value, // ISO 8601 format
    "birthNumber": form.querySelector('#birthNumber').value,
    "phoneNumber": form.querySelector('#phoneNumber').value,
    "insuranceCompany": selectedInsurance
  };


  fetch('/Insurance/register', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Accept': 'application/json',
      'Origin': 'http://localhost:8080'
    },
    body: JSON.stringify(data)
  })
    .then(response => {
      console.log('Response status code:', response.status);

      if (!response.ok) {
        throw new Error(`Registration failed with status: ${response.status}`);
      }

      console.log('Registration successful!');
      window.location.href = "/Insurance/login";

    })
    .catch(error => {
      console.error('Error during registration:', error.message);
    });
}
POST METHOD  this method save correctly data with status 200 in postman ...

@PostMapping(value = “/register”, consumes = {“application/json”},produces = {“application/json”})
public ResponseEntity<?> registerUser(@RequestBody RegistrationForm registrationForm) {

System.out.println(registrationForm.toString());

Client client = clientService.createClient(registrationForm);

ClientDAO dao = new ClientDAO(sessionFactory);
if (validateClient(client)) {
    if (dao.saveClient(client)) {

        return ResponseEntity.ok().body("Registration was successful!");

    } else {
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save the client.");
    }
} else {
    return ResponseEntity.badRequest().body("Please provide all necessary information to complete registration");
}

}



[headers in postman ](https://i.stack.imgur.com/jLYWl.png)
[request body](https://i.stack.imgur.com/UPrDi.png)
I was trying this in postman and registration was succesfull with status 200, also in chrome DevTools 
[devTools](https://i.stack.imgur.com/2mEXD.png)
[error in browser](https://i.stack.imgur.com/kuJEk.png)








How to prevent external script from top level navigation

On our site, external scripts (all Javascript) occasionally navigate the user to some malware site.

Any JS-code can be loaded from the ad provider (e.g. sometimes it creates an iframe to display the ad, sometime the ad is displayed in the main page).

I wonder how to safely prevent any external script from triggering top level navigation, whether the script is executed from within an iframe or not.

Current solution is to add CSP sandbox header in every response:

header( 'Content-Security-Policy: sandbox allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-storage-access-by-user-activation allow-top-navigation-by-user-activation allow-top-navigation-to-custom-protocols;' );

The strategy is to prevent top level navigation by omitting the sandbox allow-top-navigation header.

Is this a sufficient solution in order to prevent top level navigation? Is there a better way to achieve this?

Making a pause before redirecting to url after a link was clicked

I would like to make a post request once a link is bring clicked and after that redirect to the url. A pause would be required to make sure that the post has enoutg time to be executed.

<a href="https://google.com/" class="click" target="_blank">Click me</a>

<script>
    $('.click').click(function() {
      // let's do this
      $.post( "https://postsomewhere.de/page=2&sort=price&direction=desc" );
      // and now it's time to open <a href> link       
    });
</script>

jQuery method preferred.

Count unique values in the HTML TABLE

I have this HTML USERS TABLE


<table id="table">
    <thead>
        <tr>
            <td>Nº</td>
            <td>NOMBRE</td>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td>Andrea</td>
        </tr>
        <tr>
            <td>2</td>
            <td>Gabriela</td>
        </tr>
        <tr>
            <td>3</td>
            <td>Gabriela</td>
        </tr>
        <tr>
            <td>4</td>
            <td>Alba</td>
        </tr>
        <tr>
            <td>5</td>
            <td>Jose</td>
        </tr>
        <tr>
            <td>6</td>
            <td>Luis</td>
        </tr>
        <tr>
            <td>7</td>
            <td>Alba</td>
        </tr>
    </tbody>
</table>

And this SCRIPT count the table Rows in a Input with ID “total__registros”

<script>    
        function totalregistros(){
        var TotalRegistros= document.getElementById("table").rows.length;
        document.getElementById("total__registros").value = "Registros: " + (TotalRegistros-1);
        }
        window.onload=totalregistros();
</script>

And the result is: “Registros: 7”

How to make to the SCRIPT count unique value only, based in the “NOMBRE” field, that is to say, the result is: “Registros: 5”

I have a php code, but is for JAVASCRIPT

SELECT COUNT(DISTINCT NOMBRE) FROM usuarios

Thank you.

Autorange BarChart with ReferenceLine using Material-UI x-chart

Using React, Material-UI, and the BarChart component – is there a standard way to autorange the Y-Axis of a stacked bar-chart so that the plot will be sure to include any ChartsReferenceLine elements, as well as the plotted data?

I have a simple BarChart with a single ChartsReferenceLine:

<BarChart
    xAxis={[{ scaleType: 'band', data: ['group A'] }]}
    series={[{ data: [4] }, { data: [1] }, { data: [2] }]}
    width={500}
    height={300}
  >
  <ChartsReferenceLine
    y={10}
    lineStyle={{ strokeDasharray: "10 5", strokeWidth: "2" }}
   />
</BarChart>

but the ChartsReferenceLine ends up off the chart since its value is so much higher than the plotted elements. I know that I can compute the max ahead of time and use the axis max to set it myself, but is there an automatic method to do this?

AWS DNS propagate in Route 53 taking too much time

I create static site in s3 , and create records in route 53 and CNAME value is s3 site url

Its working fine, site available on browser

If I am doing these steps manually DNS propagate will work quickly but taking for around 30 minutes if I am doingit through AWS-SDK nodejs from my application

let changeResourceRecordSetsParams = {
    ChangeBatch: {
        Changes: [
            {
                Action: action,
                ResourceRecordSet: {
                    Name: domain,
                    TTL: 60,
                    Type: "CNAME",
                     
                    ResourceRecords: [
                        {
                          Value: s3BucketName
                        }
                      ]

                }
            }
        ]
    },
    HostedZoneId: "***"
};

Is there any difference between doing manually and doing with aws-sdk ? How can I avoid this delay ?

JS Fetch does not receive returned value from PHP

I have a simple php function that queries the database and returns a message. In javascript I am using fetch to get the response and display it on the browser.

I know for certain that the php script runs, and stores the correct message in the $responseMessage variable. In Javascript when I log the response in the console, it is empty instead of containing the correct message from php.

I have tried messing with the type being returned, although this didn’t seem to make a difference to the code not returning anything at all…

return json_encode($responseMessage) vs
return $responseMessage

I also tried changing how it’s handled in fetch.

.then(response => console.log(response.text()))
result is:

Promise {<pending>}
[[Prototype]]: Promise
[[PromiseState]]: "fulfilled"
[[PromiseResult]]: ""
______
checkin.js:40 Response data: undefined

vs

.then(response => console.log(response.text))
result is:

ƒ text() { [native code] }

I also tried logging the response status and headers as below – I get status 200, and no headers (Headers {}).
console.log("Response data:", data);
logs 'Response data: '

**javascript:
**

var checkinForm = document.getElementById('checkinform');
 checkinForm.addEventListener('submit', checkin);

function checkin(event) {
    event.preventDefault();

    var submitButton = event.submitter;
    var submitButtonName = submitButton.name;
    var submitButtonValue = submitButton.value;

    var formData = new FormData(this);
    formData.append(submitButtonName, submitButtonValue);

    fetch('handler.php', {
      method: 'POST',
      body: formData
    })
    .then(response => {
      console.log("Response Status:", response.status);
      console.log("Response Headers:", response.headers);
      return response.text();
    })
    .then(data => {
      console.log("Response data:", data);

      try {
        const parsedData = JSON.parse(data);
        if (parsedData.error) {
          console.error(parsedData.error);
        } else if (parsedData.message) {
          document.getElementById('response').innerHTML = parsedData.message;
          updateCheckinForm();
        } else {
          console.error('Unexpected response:', parsedData);
        }
      } catch (error) {
        console.error('Error parsing response JSON:', error);
      }
    })
    .catch(error => console.error('Error:', error));
  }

**php:
**

<?php
include("utilities.php");
session_start();

if ($_SERVER["REQUEST_METHOD"] === "POST") {
    if (isset($_POST["welcome-submit"])) {
        run_checkin();
    } else if (isset($_POST["transfer-submit"])) {
        run_transfer();
    } else if(isset($_POST["claim-submit"])){
        run_claim();
    } else{
        return "Invalid form submission";
    }
}


function run_checkin() {
  $con = connectDB(); //function in utilities.php, connects to database

  if (!$con) {
    $response = ['error' => 'Unable to connect to the database.'];
    return $response;
  }

  $username = $_SESSION['username']; 

  $checkinsWithinLastHour = getCheckinsFromLastHour(); //function in utilities.php
  $responseMessage = '';

  if (!$checkinsWithinLastHour) {
      error_log("!checkinsWithinLastHour");
      $responseMessage = "Error fetching check-ins within the last hour.";
  }

  // Check if the user has already checked in within the last two hours
  ...

  if ($userAlreadyCheckedIn) {
      $responseMessage = "'$username' already checked in within the last two hours.";
  } else {
      // User not checked in within the last two hours, insert checkin record
      ...
  }
  error_log($responseMessage);
  header('Content-type: application/json')
  return json_encode($responseMessage);
  $con->close();
}

...
?>

Error in specifying documentID while creating document in Appwrite Collection

I am trying to create a document in appwrite
`

const read = await this.databases.createDocument(config.databaseID, config.userReadCollectionID, JSON.stringify(data),ID.unique());

But i am getting this error.
AppwriteException: Invalid documentIdparam: Parameter must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char

I tried slicing the uniqueId to below 36 but it still doesn’t works

How to smoothly implement arrow key movement into a JavaScript game? [closed]

I’ve seen a lot of posts to try and fix something like this but nothing has worked for me so far. I need to find a way to detect arrow keys but it instantly turns when pressing another key and I’m also trying to find out how to make diagonal keys. I’m using code kind of like this…

var key;
onkeydown = e => {
    if(e.keyCode == 37) {
        // left key
    };
    if(e.keyCode == 38) {
        // up key
    };
    if(e.keyCode == 39) {
        // right key
    };
    if(e.keyCode == 40) {
        // down key
    };
};

Select Customer before creating order pos odoo 16

I need help regarding javascript logic in odoo16.

First of all, when I start before creating an order, I need to show the PartnerListCream view to select the client before proceeding to create the order.

I got it to work, but now if the cashier has a pin it does not show me the view so I can add the cashier’s pin and start the flow of selecting a customer and then creating the order attached to what I did.

odoo.define("pos_customer_required.ProductScreen", function (require) {
    "use strict";
    console.log("SE cargo3");
    const ProductScreen = require("point_of_sale.ProductScreen");
    const Registries = require("point_of_sale.Registries");
    const PartnerListScreen = require("point_of_sale.PartnerListScreen"); 
    const { useListener } = require("@web/core/utils/hooks");


    // Registries.Component.extend(ProductScreen, PosRequiredCustomerProductScreen,PartnerListScreen);

    const PosRequiredCustomerProductScreen = (ProductScreen) =>
        class extends ProductScreen {
            onMounted() {
              console.log("Start -----TESTT");
              if (this.env.pos.config.require_customer === "order") {
                this.onClickPartner();
              };
            }

        };


  
    Registries.Component.extend(ProductScreen, PosRequiredCustomerProductScreen);

    return PosRequiredCustomerProductScreen;
});

require_customer

require_customer is a parameter that I create as a configuration that if active, it is required to select a customer before creating the order and the onClickPartner method is native to Odoo, it is the event that simulates to open the view and select a customer.

Finally, as I mentioned, the view to select the customer appears before creating the order, but at no time does it now show me the view to place the cashier’s pin.

document.getElementById don’t work on raspberry pi5

My js code :

var GetTime = function()
{
  document.getElementById("time").innerHTML = new Date().toLocaleString("fr-CH",{timeZone:'Europe/Zurich',timeStyle:'medium',hourCycle:'h23'});
}
GetTime();
setInterval(GetTime,1000);

my html code :

<div id="main">
  <div class="horloges">
    <h1>Time</h1>
    <p id="time"></p>
  </div>
</div>

Can you help me ?
I work on Raspberry pi 5

Thank you

amplify version `GLIBC_2.28′ not found (required by node)

There were lot of other questions related to this, however, I’m looking solutions specifically for amplify.

Here is my amplify build logs:

2024-01-14T16:14:17.626Z [INFO]: # Cloning repository: [email protected]:anay-208/portfolio.git
2024-01-14T16:14:19.076Z [INFO]: 
2024-01-14T16:14:19.077Z [INFO]: Cloning into 'portfolio'...
2024-01-14T16:14:19.077Z [INFO]: # Switching to commit: 893dd0dc396a332bc2055fe3df3086a8e20ecde9
2024-01-14T16:14:19.090Z [INFO]: Note: switching to '893dd0dc396a332bc2055fe3df3086a8e20ecde9'.
                                 You are in 'detached HEAD' state. You can look around, make experimental
                                 changes and commit them, and you can discard any commits you make in this
                                 state without impacting any branches by switching back to a branch.
                                 If you want to create a new branch to retain commits you create, you may
                                 do so (now or later) by using -c with the switch command. Example:
                                 git switch -c <new-branch-name>
                                 Or undo this operation with:
                                 git switch -
                                 Turn off this advice by setting config variable advice.detachedHead to false
                                 HEAD is now at 893dd0d Update email address in Introduction component
2024-01-14T16:14:19.134Z [INFO]: Successfully cleaned up Git credentials
2024-01-14T16:14:19.134Z [INFO]: # Checking for Git submodules at: /codebuild/output/src504315270/src/portfolio/.gitmodules
2024-01-14T16:14:19.141Z [INFO]: # Retrieving environment cache...
2024-01-14T16:14:19.173Z [WARNING]: ! Unable to write cache: {"code":"ERR_BAD_REQUEST","message":"Request failed with status code 404"})}
2024-01-14T16:14:19.173Z [INFO]: ---- Setting Up SSM Secrets ----
2024-01-14T16:14:19.173Z [INFO]: SSM params {"Path":"/amplify/d36nuq8xnduv8k/main/","WithDecryption":true}
2024-01-14T16:14:20.188Z [INFO]: No live updates for this build run
2024-01-14T16:14:20.191Z [INFO]: # Retrieving cache...
2024-01-14T16:14:20.220Z [INFO]: # Retrieved cache
2024-01-14T16:14:46.137Z [INFO]: ## Starting Backend Build
                                 # Starting phase: build
                                 # Executing command: nvm install 20
2024-01-14T16:14:47.024Z [INFO]: Downloading and installing node v20.11.0...
2024-01-14T16:14:47.157Z [WARNING]: Downloading https://nodejs.org/dist/v20.11.0/node-v20.11.0-linux-x64.tar.gz...
2024-01-14T16:14:47.275Z [WARNING]: ###############
2024-01-14T16:14:47.277Z [WARNING]: ##########                                                 35.6%
2024-01-14T16:14:47.375Z [WARNING]: ##############################
2024-01-14T16:14:47.376Z [WARNING]: ###########                                 58.2%
2024-01-14T16:14:47.477Z [WARNING]: ##########
2024-01-14T16:14:47.477Z [WARNING]: #############################################                   76.6%
2024-01-14T16:14:47.551Z [WARNING]: ###########################
2024-01-14T16:14:47.552Z [WARNING]: ############################################# 100.0%
2024-01-14T16:14:47.572Z [WARNING]: Computing checksum with sha256sum
2024-01-14T16:14:47.688Z [WARNING]: Checksums matched!
2024-01-14T16:14:48.949Z [INFO]: Now using node v20.11.0 (npm v)
2024-01-14T16:14:48.977Z [INFO]: Installing default global packages from /root/.nvm/default-packages...
                                 npm install -g --quiet [email protected]
2024-01-14T16:14:48.979Z [WARNING]: node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)
                                    node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node)
2024-01-14T16:14:48.979Z [WARNING]: Failed installing default packages. Please check if your default-packages file or a package in it has problems!
2024-01-14T16:14:48.980Z [INFO]: # Executing command: nvm use 20
2024-01-14T16:14:49.436Z [INFO]: Now using node v20.11.0 (npm v)
2024-01-14T16:14:49.438Z [INFO]: # Executing command: npm ci
2024-01-14T16:14:49.438Z [WARNING]: node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)
                                    node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node)
2024-01-14T16:14:49.439Z [ERROR]: !!! Build failed
2024-01-14T16:14:49.439Z [INFO]: Please read more about Amplify Hosting's support for SSR frameworks to find if your build failure is related to an unsupported feature: https://docs.aws.amazon.com/amplify/latest/userguide/amplify-ssr-framework-support.html. You may also find this troubleshooting guide useful: https://docs.aws.amazon.com/amplify/latest/userguide/troubleshooting-ssr-deployment.html
2024-01-14T16:14:49.439Z [ERROR]: !!! Non-Zero Exit Code detected
2024-01-14T16:14:49.439Z [INFO]: # Starting environment caching...
2024-01-14T16:14:49.439Z [INFO]: # Environment caching completed
Terminating logging...

Here is my amplify.yml:

version: 1
backend:
  phases:
    build:
      commands:
        - nvm install 20
        - nvm use 20
        - npm ci
        - npx amplify pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: .next
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

I believe I got this solution after updating nextjs to latest stable version(^14.0.4)

You can also view the source code of this project

Any help is appreciated