Making a function inside an if statement run until you get a false value for the conditional using JS in Cypress

I am writing a test in Cypress where I enter two values into two separate inputs and then compare them by clicking a button. If the button displays “=”, I need to reset and reenter two new values until I get something other than “=”. It could be “+” or “-“.

I created a function called checkResult() that uses an if statement to check if the conditional is true (text === “=”). If it is true, it then calls another function called reEnterInputs(), which resets the value of the inputs and enters two new values.
The issue I am having is that I thought that by using this.reEnterInputs() in the if statement, it would rerun itself until I got a value other than “=”. It runs once and it stops. Can someone help?

 describe('template spec', () => {        
          const numberArray = [0, 1, 2, 3, 4, 5, 6, 7, 8];
          const  topInput = Math.floor(Math.random() * numberArray.length).toString();
          const  bottomInput = Math.floor(Math.random() * numberArray.length).toString();
           it('Check values inside html element', () => {
            cy.visit('/');
            //Fills out one input
            cy.get('#top').type(topInput);
            //Fills out another input
            cy.get('#bottom').type(bottomInput);
            //clicks button to compare
            cy.get('#compare').click();
            //Runs this function
            checkResult();
          });
        });
        
        **Functions***
    //This function checks the result of the values in the top and bottom inputs
      public checkResult() {
        cy.get('#value')
          .invoke('text')
          .then((text) => {
            if (text === '=') {
              this.reEnterInputs();
              //if the "=" appears again after running reEnterInputs(), I need reEnterInputs() to run again until a value different than "=" is given
            } else {
              cy.log('B');
            }
          });
      }
    
    //This function runs in the if statment
      public reEnterInputs() {
        let numArr = [0, 1, 2, 3, 4, 5, 6, 7, 8];
        let topNumber = Math.floor(Math.random() * numArr.length).toString();
        let bottomNumber = Math.floor(Math.random() * numArr.length).toString();
    
        //Clicks the reset button
        cy.get('#resetValues').click();
        //reenters the number in the inputs
        cy.get('#top').type(topNumber);
        cy.get('#bottom').type(bottomNumber);
        //checks value of inputs
        cy.get('#compare').click();
      }

JS file not executed when coming back to a page in SPA

I’m building an SPA where the router function calls the server and receives JSON response like

{
   "content": ...,
   "css": ...,
   "js": ...
}

and puts everything in the right place while also removing the old content. The problem is with js files (not inline scripts). On first load of the page, they get executed just fine. Then I navigate to page 2, the js of page 1 are removed. I then press the back button, which does trigger the router function and loads the content of page 1 along with js files. The script tags are created but the js never executes. Here’s the code for creating the script tags.

   function loadScript(url, type = null){
        const script = document.createElement('script');
        script.src = url;
        if(type != null)
            script.type = type;
        script.classList.add('page-js');
        document.body.appendChild(script);

        return new Promise((res, rej) => {
          script.onload = () => {
            console.log(script, 'script loaded'); // executes everytime
            res();
          };
          script.onerror = rej;
        });
   }

I tried wrapping my code in a SIAF but that didn’t make a difference. If I make the url unique like this, then the code executes.

script.src = url+'?v='+Math.random();

So most likely its a caching problem but if I do a page refresh (not handled by router), the code executes again without v parameter. What is the appropriate way of handling this in an SPA?

How to Fix ‘Undefined Variable’ Error in JavaScript?

I’m working on a JavaScript project, and I’ve encountered an issue with an “undefined variable” error. Here is the relevant part of my code:

                      function calculateSum(a, b) {
                              return a + b + c;
                              }
                       let result = calculateSum(5, 10);
                       console.log(result);

When I run this code, I get the following error in the console:

                             Uncaught ReferenceError: c is not defined
                             at calculateSum (script.js:2)
                             at script.js:5

I understand that the error is because c is not defined, but I’m not sure how to fix it. Could someone explain what I need to do to resolve this error?

I’ve checked the variable names to make sure there are no typos.
I’ve tried declaring c inside the function, but I need it to be dynamic based on some conditions.
Any help or suggestions would be appreciated. Thanks!

jsstore indexeddb not allowing multiple ! values in regex expression

When we are firing the below query on jsstore DB the multiple ‘!’ values are not executed; ideally the result was expected that it should return data of all countries whose name not brazil & mexico. Any way to achieve this?

select({
from: ‘Customers’,
where: {
country: {
regex: /!mexico|!brazil/i
}
}
})

Multiple not conditions to be added in where clause like notin

Third Person perspective – Three js

I’m working on a Three.js project where I need a third-person camera setup that follows a 3D model as it moves around the scene. I have a basic implementation with animations and controls, but I’m struggling to make the camera follow the model properly. Here’s a summary of what I’m trying to achieve and the current issues I’m facing:

Problem Summary:

I want the camera to follow the model from a third-person perspective. Specifically, as the model moves in different directions (forward, backward, left, right), the camera should always follow the model while maintaining a fixed distance and orientation.

Current Implementation:

<script setup>
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { onMounted, ref } from 'vue';

const container3D = ref(null);

onMounted(() => {
    let object, mixer, walkAction, shutdownAction, CycleBackAction, jumpAction;
    const scene = new THREE.Scene();
    scene.background = new THREE.Color(0xf0f0f0);
    const cameraOffset = new THREE.Vector3(0, 30, -50); 
    const camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 1, 5000);

    scene.add(camera);

    const renderer = new THREE.WebGLRenderer();
    renderer.setSize(window.innerWidth, window.innerHeight);
    container3D.value.appendChild(renderer.domElement);

    const loader = new GLTFLoader();
    loader.load(
        '/medium_mech_striker/scene.gltf',
        (gltf) => {
            object = gltf.scene;
            object.scale.set(10, 10, 10);
            object.position.y = -200;
            object.rotateY(Math.PI);
            object.frustumCulled = false;
            scene.add(object);

            // Setup animations
            mixer = new THREE.AnimationMixer(object);
            gltf.animations.forEach((clip) => {
                if (clip.name === 'a5WalkCycle') {
                    walkAction = mixer.clipAction(clip);
                    walkAction.setEffectiveTimeScale(1); // Adjust this value to control the speed of the walk animation
                } else if (clip.name === 'a1ShutdownPose') {
                    shutdownAction = mixer.clipAction(clip);
                } else if (clip.name === 'a6WalkCycleBack') {
                    CycleBackAction = mixer.clipAction(clip);
                } else if (clip.name === 'a8Jump') {
                    jumpAction = mixer.clipAction(clip);
                }
            });

            // Start with shutdown animation
            if (shutdownAction) {
                shutdownAction.play();
            }
        },
        undefined,
        (error) => {
            console.error('An error happened while loading the GLTF model:', error);
        }
    );

    // Create plane mesh
    const planeGeometry = new THREE.PlaneGeometry(10000, 10000);
    planeGeometry.rotateX(-Math.PI / 2);
    const planeMaterial = new THREE.ShadowMaterial({ color: 0x000000, opacity: 0.2 });

    const plane = new THREE.Mesh(planeGeometry, planeMaterial);
    plane.receiveShadow = true;
    scene.add(plane);

    const GridHelper = new THREE.GridHelper(2000, 100);
    GridHelper.position.y = -199;
    GridHelper.material.opacity = 0.25;
    GridHelper.material.transparent = true;
    scene.add(GridHelper);

    // Light
    scene.add(new THREE.AmbientLight(0xf0f0f0, 3));
    const light = new THREE.SpotLight(0xffffff, 4.5);
    light.position.set(0, 1500, 200);
    light.angle = Math.PI * 0.2;
    light.decay = 0;
    light.castShadow = true;
    light.shadow.camera.near = 200;
    light.shadow.camera.far = 2000;
    light.shadow.bias = -0.000222;
    light.shadow.mapSize.width = 1024;
    light.shadow.mapSize.height = 1024;
    scene.add(light);

    // Orbit controls
    const controls = new OrbitControls(camera, renderer.domElement);
    controls.enableDamping = true;
    controls.dampingFactor = 0.25;
    controls.screenSpacePanning = false;

    // Handle keyboard input
    const keys = {};
    window.addEventListener('keydown', (event) => {
        keys[event.key] = true;
    });
    window.addEventListener('keyup', (event) => {
        keys[event.key] = false;
    });

    // Animation function
    function animate() {
        requestAnimationFrame(animate);

        // Update mixer if defined
        if (mixer) {
            mixer.update(0.03); // Adjust this value to control the overall animation update speed
        }

        // Handle animations
        if (object) {
            if (keys['w']) {
                if (shutdownAction && shutdownAction.isRunning()) {
                    shutdownAction.stop();
                }
                if (walkAction && !walkAction.isRunning()) {
                    walkAction.play();
                }

                if (keys['d']) {
                    object.rotation.y += 0.05;
                } else if (keys['a']) {
                    object.rotation.y -= 0.05;
                } else if (keys[' ']) {
                    if (!jumpAction.isRunning()) jumpAction.play();
                } else {
                    if (jumpAction.isRunning()) jumpAction.stop();
                }

                const direction = new THREE.Vector3();
                object.getWorldDirection(direction);
                object.position.addScaledVector(direction, 1);
            } else if (keys['s']) {
                if (walkAction && walkAction.isRunning()) {
                    walkAction.stop();
                }

                if (CycleBackAction && !CycleBackAction.isRunning()) {
                    CycleBackAction.play();
                }

                const direction = new THREE.Vector3();
                object.getWorldDirection(direction);
                object.position.addScaledVector(direction, -1);
            } else {
                if (walkAction && walkAction.isRunning()) {
                    walkAction.stop();
                }
                if (shutdownAction && !shutdownAction.isRunning()) {
                    shutdownAction.play();
                }
                if (CycleBackAction && CycleBackAction.isRunning()) {
                    CycleBackAction.stop();
                }
            }
        }
        // Update camera position to follow the object
        const objectPosition = new THREE.Vector3();
        object.getWorldPosition(objectPosition);

        // Calculate camera position based on object position and offset
        const offset = cameraOffset.clone();
        offset.applyMatrix4(object.matrixWorld);
        camera.position.copy(objectPosition).add(offset);

        // Ensure camera always faces the object
        camera.lookAt(objectPosition);

        controls.update();
        renderer.render(scene, camera);
    }

    // Start animation
    animate();

    // Adjust camera and renderer size when window is resized
    window.addEventListener('resize', () => {
        camera.aspect = window.innerWidth / window.innerHeight;
        camera.updateProjectionMatrix();
        renderer.setSize(window.innerWidth, window.innerHeight);
    });
});
</script>

Issue:

The camera currently doesn’t follow the model’s movements. The camera remains static and doesn’t adjust its position or orientation based on the model’s position or rotation.

What I’ve Tried:

I have set up the camera and renderer properly.
I’ve implemented animation controls for moving and rotating the model.
I’ve used OrbitControls to manage the camera view.

Questions:
How can I modify the camera setup so that it follows the model from a third-person perspective?
What changes are needed in the code to ensure that the camera maintains a fixed distance from the model while it moves around?
Any guidance or suggestions would be greatly appreciated. Thank you!

Dropdown selector in WS Form must select layers in LayerSlider same form

your textNeed that when a customer selects a product from dropdown selector of the my WS Form, he can see an image of the product in the same form using a window with LayerSlider.

your textMy data:
your textDropdown selector ID = 5277
your textProduct1 = DAA1186
your textProduct2 = DAA1187
your textProduct3 = DAA1189
your textProduct4 = DAA1244
your textLayerslider ID = 10
your textLauer = 1
your textLayer = 2
your textLayer = 3
your textLayer = 4

    jQuery(document).ready(function($) {
    $('#5277').change(function() {
    var selectedValue = $(this).val();
    if (selectedValue === 'DAA1186') {
    layersliderInstance.showSlide(1);   
    else if (selectedValue === 'DAA1187') {
    layersliderInstance.showSlide(2);
    else if (selectedValue === 'DAA1189') {
    layersliderInstance.showSlide(3);
    else if (selectedValue === 'DAA1244') {
    layersliderInstance.showSlide(4); }
    var layersliderInstance = $('#10').layerSlider({     
    });
    });
    }); 

your textIt’s don’t work and I don’t see the error, but the console says something else. The specified value “0)” cannot be parsed, or is out of range. jquery.min js?ver=3.7.1:2.

Screen capture popup keeps swapping the applications windows

I’m developing a site that uses the Screen Capture API to capture a game’s windows and check the screenshots taken to notify user of some scenarios.

My problem here is when we open the Screen Capture popup to choose which application window I want to capture, all the applications on the popup keep changing it’s location inside it, so it gets very difficult to select the correct application’s window. I presume that the popup keeps checking if there are new open windows to add on it, and since all the game windows have the same name, the ordenation just don’t take it in mind. Anyway, is there any way to avoid this behavior?

The Screen Capture API is an inbuilt API, so I dont control the popup, nor how the window selection is made. This is how the selection is started:

    const displayMediaOptions = {
        video: {
            displaySurface: "window",
            cursor: "hidden"
        },
        audio: false,
    };

videoElem!.srcObject =
                    await navigator.mediaDevices.getDisplayMedia(displayMediaOptions);

I’ve tested on google chrome, edge and firefox last versions on windows 10. All have this same behavior.

Here a video for better understanding:
https://youtu.be/6QKnYghi-Cc

Thanks

Sửa Tủ Lạnh Gần Đây Limosa

Dịch Vụ Sửa Tủ Lạnh Gần Đây Giá Rẻ, Uy Tín – Sửa Tủ Lạnh Limosa
Bạn đang cần tìm kiếm địa chỉ sửa tủ lạnh gần đây nhưng chưa biết nên lựa chọn trung tâm nào. Sửa Tủ Lạnh Limosa tự tin là một trong số các trung tâm sửa tủ lạnh số một tại Hồ Chí Minh.

  1. Những lỗi thường gặp ở tủ lạnh
    Tủ lạnh không hoạt động được dù đã cắm nguồn, cắm điện.
    Tủ lạnh quá lạnh hoặc làm lạnh kém so với ngày thường.
    Trong lúc hoạt động tủ lạnh phát ra tiếng ồn lớn.
    Đèn tủ lạnh không sáng khi tủ hoạt động
    Cửa tủ lạnh không đóng được, cánh cửa tủ bị xệ.
    Tủ lạnh bị rò rỉ nước ra sàn không rõ nguyên nhân
    Ống dẫn gas của tủ có vấn đề, tủ lạnh hết ga, xì gas
    Board tủ lạnh bị hư hỏng
    Block tủ lạnh không hoạt động
    Thực phẩm trong tủ lạnh không được bảo quản.
    Khi tủ lạnh nhà bạn gặp phải những sự cố trên hãy liên hệ ngay với dịch vụ sửa tủ lạnh Limosa để được giúp đỡ nhé.
  2. Các bước sửa tủ lạnh tại nhà của Trung tâm Sửa Tủ lạnh Limosa

Với nhiều năm kinh nghiệm trong lĩnh vực điện lạnh, Limosa luôn là địa chỉ tin cậy của nhiều khách hàng khi có nhu cầu sửa tủ lạnh. Trung tâm Limosa vẫn luôn nhận được đánh giá cao từ khách hàng là vì quy trình sửa chữa tủ lạnh của chúng tôi được thực hiện rất chuyên nghiệp, an toàn . Cụ thể :
Bước 1: Ghi nhận thông tin
Bộ phận CSKH tiếp nhận thông tin của những khách hàng có nhu cầu sửa chữa tủ lạnh gần đây thông qua số điện thoại 0909.114.796 hoặc trang web Suatulanhlimosa.com
Bước 2: Điều phối kỹ thuật viên
Ngay sau khi xác nhận về thời gian và địa chỉ cụ thể với khách hàng, kỹ thuật viên sẽ được điều phối có mặt tận nơi để tiến hành cung cấp dịch vụ
Bước 3: Kiểm tra hiện trạng của tủ lạnh
Sau khi có mặt nhân viên kỹ thuật tiến hành kiểm tra tình trạng của tủ lạnh để tìm ra lỗi sự cố và nguyên nhân gây ra hư hỏng.
Bước 4: Phân tích nguyên nhân hỏng hóc và giải pháp sửa chữa cho khách hàng
Nắm được lỗi và nguyên nhân dẫn đến sự cố của tủ lạnh, kỹ thuật viên sẽ trình bày để khách hàng hiểu từ đó đưa ra phương pháp sửa chữa tối ưu nhất.
Bước 5: Báo giá cho khách hàng
Căn cứ vào tình trạng hỏng hóc thực tế của tủ cùng với mức giá dịch vụ sửa tủ lạnh đã niêm yết của trung tâm, nhân viên sẽ báo giá chi tiết cho bạn.
Bước 6: Bắt đầu công việc sửa chữa cho tủ lạnh
Sau khi thống nhất với khách hàng về chi phí và phương án sửa chữa, kỹ thuật viên sẽ bắt đầu thực hiện
Bước 7: Bàn giao lại tủ lạnh và thu phí, tư vấn sử dụng.
Sau khi hoàn thành xong việc sửa chữa, nhân viên kỹ thuật sẽ cho khởi động lại tủ để kiểm tra xem có bất cứ vấn đề nào nữa không sau đó mới bàn giao lại thiết bị và tiến hành thu phí dịch vụ.
Bước 8: Sau 03 ngày sửa tủ lạnh, nhân viên chăm sóc khách hàng sẽ chủ động liên lạc lại để nắm được tình hình hoạt động của tủ đồng thời giải đáp những vướng mắc của khách hàng về dịch vụ sửa chữa tủ lạnh.
3. Cam kết khi lựa chọn dịch vụ sửa tủ lạnh của Trung tâm Sửa Tủ Lạnh Limosa
Để đáp lại sự tin tưởng của khách hàng khi đã sử dụng dịch vụ sửa tủ lạnh gần nhất của trung tâm, chúng tôi cam kết rằng :
Cam kết khắc phục triệt để 100% tất cả các lỗi mà tủ lạnh đang gặp phải, chẩn đoán đúng bệnh, đúng lỗi.
Thời gian có mặt nhanh chóng theo đúng lịch hẹn, không để khách hàng phải chờ đợi lâu.
Cam kết quá trình sửa chữa tủ lạnh nhanh gọn, trang thiết bị làm việc hiện đại.
Đảm bảo 100% nhân viên kỹ thuật tham gia quá trình sửa chữa cho tủ lạnh đều có kinh nghiệm và tay nghề cao trong lĩnh vực điện lạnh.
Cam kết trong quá trình sửa chữa tủ lạnh không đánh cắp, đánh tráo bất cứ linh phụ kiện gốc của tủ
Trong trường hợp cần thay thế phụ kiện đảm bảo tất cả đều là hàng chính hãng 100%, có nguồn gốc và xuất xứ rõ ràng. Limosa nói không với những hàng hóa giả, hàng kém chất lượng trôi nổi trên thị trường.
Cam kết thống nhất giá cả với khách hàng ngay từ đầu, không thu thêm bất cứ phụ phí nào khác ngoài mức giá đã thống nhất. Chúng tôi sẽ chỉ tính phí khi khách hàng đồng ý sử dụng dịch vụ, miễn phí hoàn toàn 100% phí kiểm tra, tư vấn sử dụng.
Cam kết hoàn lại 100% tiền sửa tủ lạnh gần đây Limosa cho khách hàng nếu không sửa chữa triệt để các lỗi của tủ
Cam kết cung cấp dịch vụ bảo hành lên đến tận 6 tháng (tùy lỗi) sau khi hoàn thành việc sửa tủ lạnh cho khách.
Trên đây là một số chia sẻ của trung tâm Limosa về dịch vụ sửa tủ lạnh. Gọi ngay cho chúng tôi theo số 0909.114.796 khi cần sử dụng các dịch vụ điện lạnh chuyên nghiệp, uy tín, giá rẻ nhé.

Dịch vụ sửa tủ lạnh Limosa muốn mang đến cho quý khách hàng dịch vụ sửa tủ lạnh giá rẻ, uy tín nhất

How to Hide Product Variants Based on Dependencies Using jQuery?

I am using WooCommerce with the Hello Elementor theme on localhost, and I have several custom fields for product variants. I want to hide a variant when specific dependency conditions are not met. I’m using the following jQuery code to check dependencies and toggle visibility:

$('#product-variants .variant-card').each(function () {
    const $variant = $(this);
    const dependencies = ($variant.data('dependencies') || '').split(',').filter(Boolean);
    const allDependenciesMet = dependencies.every(dependencyIndex => {
        const dependentVariant = $('[data-variant-index="' + dependencyIndex + '"]');
        const quantity = parseInt(dependentVariant.find('input[type="range"]').val(), 10) || 0;
        return quantity > 0; // Check if quantity is more than 0
    });

    if (!allDependenciesMet) {
        $variant.hide(); // Hide variant if dependencies are not met
    } else {
        $variant.show(); // Show variant if all dependencies are met
    }
});

The issue is that the variants hide correctly at first when the page loads, but then the display property quickly changes back to block almost immediately (less than a second), causing the variants to reappear.

I am not using any other plugins that might interfere with this logic only woocommerce is installed in my localhost.

  • Why is the display property reverting to block?
  • and how can I ensure that the variants remain hidden when their dependencies are not met?

Any insights or solutions would be greatly appreciated!

SPA Application become significantly slower when the route is changed repeatedly. Please find attached the firefox performance and memory profile

SPA Application become significantly slower when the route is changed repeatedly. Please find attached the firefox performance and memory profile.This is a Vue Quasar App. Application is quite fast in the beginning. But, when I keep switching the pages to be loaded, it becomes slower and slower. Memory snapshots doesn’t vary much in MB. It decreases also at times.

Firefox Performance profile link: https://profiler.firefox.com/public/yrnk8amaz8dv64qzc55qd2v3f3861fhag2raz48/calltree/?globalTrackOrder=0w2&implementation=js&thread=3&v=10

Memory Profile:
enter image description here

Which webpack hooks can hooking into dynamic import

I write a webpack plugin which collect informations of import. I use parser.hooks.import hooking into import statement like import xxx from 'xxx'. but for dynamic import like const yy = import('yy'). is there a hook can hooking it.

I try parser.hooks.call.for('import') and parser.hooks.expression.for('import'), but they don’t works. which hooks should i use??

Problems installing image packages for javascript application

I am following the course from Johnatan Mircha for Node.js in this video. I am developing the final application at the end of the video for the optimization of image files. However, when installing the packages in the devDependencies of the package.json,

{
  "name": "imgopt",
  "version": "1.0.0",
  "description": "Creando una app en Node.js para optimizar imágenes para la web",
  "main": "app.js",
  "type": "module",
  "scripts": {
    "start": "node app.js"
  },
  "keywords": [],
  "author": "Jonathan MirCha",
  "license": "MIT",
  "devDependencies": {
    "fs-extra": "^11.1.1",
    "imagemin": "^8.0.1",
    "imagemin-gifsicle": "^7.0.0",
    "imagemin-jpegtran": "^7.0.0",
    "imagemin-pngquant": "^9.0.2",
    "imagemin-svgo": "^10.0.1",
    "imagemin-webp": "^8.0.0",
    "sharp": "^0.32.4"
  }
}

I am obtaining the following error

npm error code 1
npm error path /media/juanessao2000/hdd/PRINCIPAL-2023-2/CURSOS/JohnatanMircha/Node_js/05_Proyectos/ImgOpt/node_modules/sharp
npm error command failed
npm error command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
npm error sharp: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.14.5/libvips-8.14.5-linux-x64.tar.br
npm error sharp: Integrity check passed for linux-x64
npm error
npm error make: Entering directory '/media/juanessao2000/hdd/PRINCIPAL-2023-2/CURSOS/JohnatanMircha/Node_js/05_Proyectos/ImgOpt/node_modules/sharp/build'
npm error   CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
npm error rm -f Release/obj.target/../node-addon-api/nothing.a Release/obj.target/../node-addon-api/nothing.a.ar-file-list; mkdir -p `dirname Release/obj.target/../node-addon-api/nothing.a`
npm error ar crs Release/obj.target/../node-addon-api/nothing.a @Release/obj.target/../node-addon-api/nothing.a.ar-file-list
npm error   COPY Release/nothing.a
npm error   TOUCH Release/obj.target/libvips-cpp.stamp
npm error   CXX(target) Release/obj.target/sharp-linux-x64/src/common.o
npm error make: Leaving directory '/media/juanessao2000/hdd/PRINCIPAL-2023-2/CURSOS/JohnatanMircha/Node_js/05_Proyectos/ImgOpt/node_modules/sharp/build'
npm error sh: 1: prebuild-install: Permission denied
npm error gyp info it worked if it ends with ok
npm error gyp info using [email protected]
npm error gyp info using [email protected] | linux | x64
npm error gyp info find Python using Python version 3.11.8 found at "/home/juanessao2000/anaconda3/bin/python3"
npm error gyp http GET https://nodejs.org/download/release/v20.16.0/node-v20.16.0-headers.tar.gz
npm error gyp http 200 https://nodejs.org/download/release/v20.16.0/node-v20.16.0-headers.tar.gz
npm error gyp http GET https://nodejs.org/download/release/v20.16.0/SHASUMS256.txt
npm error gyp http 200 https://nodejs.org/download/release/v20.16.0/SHASUMS256.txt
npm error gyp info spawn /home/juanessao2000/anaconda3/bin/python3
npm error gyp info spawn args [
npm error gyp info spawn args '/home/juanessao2000/.nvm/versions/node/v20.16.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm error gyp info spawn args 'binding.gyp',
npm error gyp info spawn args '-f',
npm error gyp info spawn args 'make',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/media/juanessao2000/hdd/PRINCIPAL-2023-2/CURSOS/JohnatanMircha/Node_js/05_Proyectos/ImgOpt/node_modules/sharp/build/config.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/home/juanessao2000/.nvm/versions/node/v20.16.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/home/juanessao2000/.cache/node-gyp/20.16.0/include/node/common.gypi',
npm error gyp info spawn args '-Dlibrary=shared_library',
npm error gyp info spawn args '-Dvisibility=default',
npm error gyp info spawn args '-Dnode_root_dir=/home/juanessao2000/.cache/node-gyp/20.16.0',
npm error gyp info spawn args '-Dnode_gyp_dir=/home/juanessao2000/.nvm/versions/node/v20.16.0/lib/node_modules/npm/node_modules/node-gyp',
npm error gyp info spawn args '-Dnode_lib_file=/home/juanessao2000/.cache/node-gyp/20.16.0/<(target_arch)/node.lib',
npm error gyp info spawn args '-Dmodule_root_dir=/media/juanessao2000/hdd/PRINCIPAL-2023-2/CURSOS/JohnatanMircha/Node_js/05_Proyectos/ImgOpt/node_modules/sharp',
npm error gyp info spawn args '-Dnode_engine=v8',
npm error gyp info spawn args '--depth=.',
npm error gyp info spawn args '--no-parallel',
npm error gyp info spawn args '--generator-output',
npm error gyp info spawn args 'build',
npm error gyp info spawn args '-Goutput_dir=.'
npm error gyp info spawn args ]
npm error gyp info spawn make
npm error gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm error ../src/common.cc:13:10: fatal error: vips/vips8: No such file or directory
npm error    13 | #include <vips/vips8>
npm error       |          ^~~~~~~~~~~~
npm error compilation terminated.
npm error make: *** [sharp-linux-x64.target.mk:138: Release/obj.target/sharp-linux-x64/src/common.o] Error 1
npm error gyp ERR! build error 
npm error gyp ERR! stack Error: `make` failed with exit code: 2
npm error gyp ERR! stack at ChildProcess.<anonymous> (/home/juanessao2000/.nvm/versions/node/v20.16.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm error gyp ERR! System Linux 5.15.0-117-generic
npm error gyp ERR! command "/home/juanessao2000/.nvm/versions/node/v20.16.0/bin/node" "/home/juanessao2000/.nvm/versions/node/v20.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm error gyp ERR! cwd /media/juanessao2000/hdd/PRINCIPAL-2023-2/CURSOS/JohnatanMircha/Node_js/05_Proyectos/ImgOpt/node_modules/sharp
npm error gyp ERR! node -v v20.16.0
npm error gyp ERR! node-gyp -v v10.1.0
npm error gyp ERR! not ok
npm error A complete log of this run can be found in: /home/juanessao2000/.npm/_logs/2024-08-05T02_43_13_229Z-debug-0.log

I tried installing each package individually but still I get problems with the installing. I have been searching for other developers questions in case someone else has had the same problem but I have not found anything that works for me.

Any advice on this installing would be really helpful. Thanks in advance!

When runing react js app, it doesn’t connect to localhost unless i go to another site (like google.com) and come back with back arrow

When i run the frontend of my app with npm start it doesn’t work. It’s like if it didn’t run at all. if i go on another website like google.com and then come back with the back arrow it works. If i refresh it doesn’t work anymore.

When i look up if there’s something running on the port i’m using it says that there’s nothing, if i do the workarround of coming back with back arrow it suddently says there’s something.

I tried reinstalling node-modules, my friend runned the code on his computer he has no issues.

The only other thing that works is running the command serve -s build after a build.

I’m clueless as to what i can do to fix this problem

I’m getting the error `Encountered two children with the same key, `t`.`

What I’m trying to do is pull a name of a football player from an NFL API then use that name as a link to their page. For this error it’s combining all the links into one link which is very weird because when I was just testing all my routes without the api it worked and did not do this. It’s outputting something like this TaaotaTarlaoaortaJoshAllen to the page instead of just each player’s name then a space and another player’s name. It should be like (Bold means link):
Tua Tagovailoa Patrick Mahomes Joe Burrow Josh Allen

Side note: I feel like it’s definitely pulling data from the api just not how I want to. It’s sorta making out the names that are pulled from the api just all as one link but I want multiple links.

This is how it worked without the API and outputted like shown below:
Special Team 1 Special Team 2 Special Team 3 Special Team 4

import { Link } from "react-router-dom"
import _navbar from "../NavBar/navbar";

export default function _specialTeamsPage() {
    const specialteams = [1, 2, 3, 4, 5];

    return (
        <>
        <_navbar />
        <div>
            {specialteams.map((specialteam) => (
                <Link key={specialteam} to={`/specialteam/${specialteam}`}>
                    Special Team {specialteam}
                </Link>
            ))}
        </div>
        </>
    );

}

This is the code block with the API that is not working:

import { Link } from "react-router-dom";
import _navbar from "../NavBar/navbar";
import React, { useEffect, useState } from "react";
import styles from './card.module.css';

export default function _quarterbacksPage() {
    const quarterbacks = [3139477, 4241479, 3918298, 3915511, 2577417];
    const [names, setNames] = useState([]);
    for (let i = 0; i < quarterbacks.length; i++){
        const options = {
            method: 'GET',
            headers: {
                'x-rapidapi-key': 'secret key',
                'x-rapidapi-host': 'nfl-api-data.p.rapidapi.com'
            }
        };
    
        const FullNameUrl = 'https://nfl-api-data.p.rapidapi.com/nfl-ath-fullinfo?id=' + quarterbacks[i];
        const fetchFullName = async () => {
            fetch(FullNameUrl, options)
            .then(response => response.json())
            .then(response => {
                const name = response.athlete.fullName;
                setNames([...names, ...name]);
                
            })
        };
    
        useEffect(() => {
            fetchFullName();
        }, []);
    }


    return (
        <>
            <div>
                <_navbar />
                {names.map((name) => (
                    <Link key={name} to={`/quarterback/${name}`}>
                    {name}
                    </Link>

                ))}
            
            </div>
        </>
    );
}

How to check if the new window request is from pressing mouse wheel in Webview2

Normally web browser will open a new tab and switch to the new tab if you clicked on <a href="" target="_blank"> or execute open() in JavaScript. And if you click a link with mouse wheel browser will open a new tab but it won’t switch the to the new tab.

The reason I need to know how the page was openned is because the way of open it will effect on what I bold in first paragraph

If you are not sure what I am talking about you can search something on Bing because Bing will open a new tab for the result’s website instead of using current tab, try to click the result with LeftClick and mouse wheel you will see the difference. I want to do something like this on WinUI3 Webview2.

It seems like there is no this kind of EventArgs in Webview2.CoreWebView2.NewWindowRequested event. I guess this can be done with JavaScript but I haven’t found any solution for it. What can I do?