npm install –prefix server not working on windows npm version 10.7.0

npm install server

is working fine.

I am using powershell inside visual studio code, I tried running powershell as adminstrator and ran this command still got error.

Package.json

{
  "name": "nasa_launch_api",
  "version": "1.0.0",
  "main": "src/server.js",
  "scripts": {
    "test": "echo "Error: no test specified" && exit 1",
    "watch": "nodemon src/server.js",
    "start": "set PORT=5000&& node src/server.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": "Nasa mission control Project",
  "dependencies": {
    "cors": "^2.8.5",
    "csv-parse": "^5.5.5",
    "express": "^4.19.2"
  },
  "devDependencies": {
    "nodemon": "^3.1.0"
  }
}

I have removed node-modules and package-lock.json and tried again it fails.

Docker Container not restarting for code Changes and node modules not getting automatically installed in docker

My Dockerfile is:

FROM node:18
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["./node_modules/.bin/nodemon", "app.js"]  // also tried with `npm start` and `npm run dev`, which did not work.

My docker-compose.yml is:

version: "3.8"
services:
  biz-ecommerce:
    container_name: biz-ecommerce
    build:
      context: .
    ports:
      - "3000:3000"
    volumes:
      - .:/app

My package.json is:

{
  "name": "biz-ecommerce",
  "version": "1.0.0",
  "description": "ecommerce website",
  "main": "app.js",
  "type": "module",
  "scripts": {
    "start": "nodemon app.js",
    "dev": "nodemon app.js"
  },
  "repository": {
    "type": "git",
    "url": "biz-ecommerce"
  },
  "author": "chetan",
  "license": "ISC",
  "dependencies": {
    "bcryptjs": "^2.4.3",
    "dotenv": "^16.4.5",
    "express": "^4.19.2",
    "jsonwebtoken": "^9.0.2"
  },
  "devDependencies": {
    "nodemon": "^3.1.0"
  }
}

My initial app.js is:

import express from 'express';
import dotenv from 'dotenv';
dotenv.config();
const app = express();

app.listen(3000, () => {
    console.log("Run successfully at PORT:3000...");
}).on('error', () => {
    console.log("error occurred");
});

Here is the issue i am facing:

Node modules are not getting installed automatically when you start docker-compose up –build, even though you used RUN npm install in your Dockerfile.
Container not restarting even after code changes are made and reflected in the working directory of the container.
Any insights or solutions to address these issues would be appreciated.

i expect the docker to start running container and when any code change occurs or save occurs on file docker should automatically restart the container whenever changes are being reflected in containeer and should install node_modules automatically.

mineflayer returning blank messages

im using mineflayer via python, and here is my code:

@On(bot, 'messagestr')
def handleServerMsg(this, message, *args):
    print(message)
    print(args)

the bot is set up correctly, and is able to log in. on some servers, including my paper test server, it prints messages correctly. however, on some servers, no text is ever returned. args would look like this:

translate: 'chat.type.text',
  with: [
    ChatMessage {
      json: [Object],
      warn: [Function],
      text: '',
      extra: [Array],
      bold: undefined,
      italic: undefined,
      underlined: undefined,
      strikethrough: undefined,
      obfuscated: undefined,
      color: undefined
    }

text is always an empty string. any ideas?

i wanted to simply print the message in console for further use. i tried many things, including listening to other events, but the text just never shows up. a nickname is always returned.

sinon stub error with ava ” Attempted to wrap myFunction which is already wrapped” despite using sinon.sandbox

I’m encountering an issue with Sinon while running my tests in parallel mode using Ava. Whenever I run my tests with ava –parallel, I get the following error:

beforeEach hook for myfile

Error thrown in test:

TypeError: Attempted to wrap myFunction which is already wrapped

Here’s a simplified version of my test setup:

import sinon from 'sinon';
import * as myModule from '../../../src/myModule';

test.beforeEach(t => {
  t.context.sandbox = sinon.createSandbox();
  t.context.sandbox.stub(myModule, 'myFunction').returns(false);
});

test.afterEach.always(t => {
  t.context.sandbox.restore();
});

What I’ve Tried:

Serial Execution: When I run my tests with ava –serial, everything works fine without any errors.

Check for Duplicate Stubs: I’ve verified that the myFunction function is only being stubbed once in my test setup and is not being stubbed elsewhere in my test file.

Additional Information:

The myFunction function is a top-level function in the myModule module and is being stubbed in a beforeEach hook for each test.

Question:

What could be causing this “attempted to wrap already wrapped function” error when running tests in parallel mode with Sinon, and how can I resolve it? I cannot seem to understand why it would try re-wrapping the same stub, if the point of the sandbox env is for each test to have it’s own instance

‘String was not recognized as a valid DateTime.’ in asmx.cs file of asp.net c#

I have Two Input Type = “Date” and one Input Type = “Button”

<input type="date" runat="server" id="dtp_from" />
<input type="date" runat="server" id="dtp_to" />
<input type="button" id="btnSubmit" CssClass="custom-btn" value="Submit" />

One GridView Table

<table id="gv_Datatable" class="table table-responsive table-hover">
    <thead>
        <tr>
            <th>Id</th>
            <th>Date</th>
            <th>Name</th>
            <th>Description</th>
            <th>Receipt</th>
            <th>Payment</th>                            
            <th>Balance</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <th>Id</th>
            <th>Date</th>
            <th>Name</th>
            <th>Description</th>
            <th>Receipt</th>
            <th>Payment</th>
            <th>Balance</th>                            
        </tr>
    </tfoot>
</table>                

Now, here when click on button ajax method is called and through parameter two date are passing to the asmx.cs file.

$("#btnSubmit").click(function (e) {                
    var dataToSend = {
        param1: JSON.stringify(document.getElementById("<%=dtp_from.ClientID%>").value),
        param2: JSON.stringify(document.getElementById("<%=dtp_to.ClientID%>").value)
    };
    $.ajax({
        type: "POST",
        url: "FillGridMethod.asmx/CashBookList",
        data: dataToSend,
        dataType: "json",
        success: function (data) {                        
            var datatableVariable = $('#gv_Datatable').DataTable({
                dom: 'Bfrtip',
                data: data,
                columns: [
                    { 'data': 'Id', visible: false },
                    {
                        'data': 'cashbookdate', 'render': function (date) {
                            var date = new Date(parseInt(date.substr(6)));
                            var month = date.getMonth() + 1;
                            return date.getDate() + "/" + month + "/" + date.getFullYear();
                        }
                    },
                    { 'data': 'cashbookaccname' },
                    { 'data': 'cashbookdescription' },
                    { 'data': 'cashbookreceipt' },
                    { 'data': 'cashbookpayment' },
                    { 'data': 'Balance' },
                    {
                        "render": function (data, type, row) { return "<a href='#' class='btn btn-success' onclick=DeleteCustomer('" + row.Id + "');>View</>"; }
                    },
                    {
                        "render": function (data, row) { return "<a href='#' class='btn btn-danger'>Delete</a>"; }
                    }]
            });
        }
    });
});

Here is the asmx.cs file code

[WebMethod(enableSession: true)]
public void CashBookList(string param1, string param2)
{
    DateTime fromDate = DateTime.ParseExact(param1, "dd/MM/yyyy", CultureInfo.InvariantCulture);

    var cashBook = new List<CashBookModel>();
    string constr = cn.ConnectionString;
    using (SqlConnection con = new SqlConnection(constr))
    {
        qryFillGrid = " select cashbookid, cashbookdate, cashbookaccname, cashbookdescription, cashbookreceipt, cashbookpayment, Balance from tbl_cashbook " + System.Environment.NewLine;
        qryFillGrid += " where BranchID = " + HttpContext.Current.Session["BranchID"] + " " + System.Environment.NewLine;
        if (HttpContext.Current.Session["AccountMode"].ToString() != "ALL")
        {
            qryFillGrid += " and AccountMode = '" + HttpContext.Current.Session["AccountMode"].ToString() + "' " + System.Environment.NewLine;
        }
        if(param1 != """")
        {                    
            qryFillGrid += " and convert(varchar(10), convert(datetime, cashbookdate,105),112) >= '" + Convert.ToDateTime(service.IfNullThen(fromDate, DateTime.Now.Date)).Date.ToString("yyyyMMdd") + "' " + System.Environment.NewLine;
            if (param2 != """")
            {
                qryFillGrid += " and convert(varchar(10), convert(datetime, cashbookdate,105),112) <= '" + Convert.ToDateTime(service.IfNullThen(param2, DateTime.Now.Date)).Date.ToString("yyyyMMdd") + "' " + System.Environment.NewLine;
            }
        }
        else
        {
            qryFillGrid += " and convert(varchar(10), convert(datetime, cashbookdate,105),112) = '" + System.DateTime.Now.Date + "' " + System.Environment.NewLine;                    
        }
        qryFillGrid += " order by cashbookdate, cashbookid desc " + System.Environment.NewLine;
        var cmd = new SqlCommand(qryFillGrid, con);
        con.Open();
        var dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            var cashBookModel = new CashBookModel
            {
                Id = Convert.ToInt32(dr[0]),
                cashbookdate = Convert.ToDateTime(dr[1]),
                cashbookaccname = dr[2].ToString(),
                cashbookdescription = dr[3].ToString(),
                cashbookreceipt = Convert.ToDecimal(service.IfNullThen(dr[4], 0)),
                cashbookpayment = Convert.ToDecimal(service.IfNullThen(dr[5], 0)),
                Balance = Convert.ToDecimal(service.IfNullThen(dr[6], 0)),
            };
            cashBook.Add(cashBookModel);
        }
    }
    var js = new JavaScriptSerializer();
    Context.Response.Write(js.Serialize(cashBook));
}

DateTime fromDate = DateTime.ParseExact(param1, “dd/MM/yyyy”, CultureInfo.InvariantCulture);

In this below line of asmx.as file getting error i.e.: ‘String was not recognized as a valid DateTime.’

How to replace text in google docs using the cell address of google sheets?

I have a doc that contains text like %A1%, %B3%, %A3%, and so on. I have a Google sheet. I want to replace the text in the Google doc from the Google sheet. The replacement is to be made like this:”%A1% will be replaced by the value in cell (1,1), i.e., the value in range”A1:A1″,”%C3% will be replaced by the value in cell (3,3), i.e., the value in range”C3:C3″ and so on. The following code is just for one cell. I want to loop through all cells in the sheet and make all replacements. Any help will be appreciated.

function myFunction() {
  var myDoc = DocumentApp.openById('docID')
  var docBody = myDoc.getActiveSection()
  var sss = SpreadsheetApp.openById('sheetID); 
  var x =  sss.getRange("A3:A3").getValues()
  docBody.replaceText('%A3%', x)
} 

Text Wrap around JQuery Draggable/Resizable Image

I am trying to use JQuery, and want images to be resizable and draggable. I also want the text to wrap around the image (does not have to be real time) when the image is dragged or resized. Right now I can get the text to the side of the image, but once I add more text that the line breaks, it just moves the paragraph down under the image/container of the image.

I have already tried just setting a float to the containing div around the image, and the image itself. It sort of works but the text breaking is wrong. Maybe I am missing something extremely obvious.

Custom HTML Text Box For Digital Piano Sheet Music

I have tried many methods, and I’m a simple beginner with JavaScript but I want to make a site where I can play a digital piano (without a piano) and have it group keys together that I press at the same time.

For example, if I press “a” then “b” then I press “c” at the same time as “d” it will format it like this: “a b [cd]”. I’ve gotten to the point to where I’ve failed so many times that I asked ChatGPT, but even it was no help.     I Wasn’t Surprised

How to decrypt this js file?

How to decrypt the javascript code like this. Ask for the specific method or a tool.:

function loadComplete() {
  if (pageNo == 0) {
    loaderplay = game[_$_2aa1[4]][_$_2aa1[14]][1][_$_2aa1[25]][_$_2aa1[29]](403, 391, _$_2aa1[127]);

    loaderplay[_$_2aa1[524]](0);

    loaderplay[_$_2aa1[525]]({
      "useHandCursor": true
    });

    game[_$_2aa1[4]][_$_2aa1[14]][1][_$_2aa1[40]][_$_2aa1[39]]({
      "delay": 10,
      "callback": _0x9CAD,
      "callbackScope": this
    });

    function _0x9CAD() {
      game[_$_2aa1[4]][_$_2aa1[14]][1][_$_2aa1[31]][_$_2aa1[526]]({
        "targets": loaderplay,
        "tweens": [{
          "angle": 30,
          "ease": _$_2aa1[30],
          "duration": 400,
          "repeat": 0,
          "yoyo": true
        }, {
          "angle": -30,
          "ease": _$_2aa1[30],
          "duration": 400,
          "delay": 200,
          "repeat": 0,
          "yoyo": true,
          "onComplete": _0x9CB7
        }]
      });
    }

    function _0x9CB7() {
      game[_$_2aa1[4]][_$_2aa1[14]][1][_$_2aa1[40]][_$_2aa1[39]]({
        "delay": 1000,
        "callback": _0x9CAD,
        "callbackScope": this
      });
    }

    loaderplay[_$_2aa1[42]](_$_2aa1[527], function (_0x9C7B) {});

    loaderplay[_$_2aa1[42]](_$_2aa1[528], function (_0x9C7B) {});

    loaderplay[_$_2aa1[42]](_$_2aa1[529], function (_0x9C7B) {
      loaderplay[_$_2aa1[530]]();

      loadngTimeEvent = game[_$_2aa1[4]][_$_2aa1[14]][1][_$_2aa1[40]][_$_2aa1[39]]({
        "delay": 1,
        "callback": loadingAsset,
        "callbackScope": this
      });

      this[_$_2aa1[4]][_$_2aa1[532]][_$_2aa1[531]](false, _$_2aa1[5]);

      game[_$_2aa1[4]][_$_2aa1[6]](_$_2aa1[49]);

      if (typeof gdsdk !== _$_2aa1[533] && gdsdk[_$_2aa1[534]] !== _$_2aa1[533]) {
        gdsdk[_$_2aa1[534]]();
      }
    });

    progress[_$_2aa1[535]] = 0;
    percentText[_$_2aa1[535]] = 0;
    loadValue++;
  } else {
    loadValue++;

    if (loadValue <= 15) {
      loadngTimeEvent = game[_$_2aa1[4]][_$_2aa1[14]][1][_$_2aa1[40]][_$_2aa1[39]]({
        "delay": 1,
        "callback": loadingAsset,
        "callbackScope": this
      });
    } else {
      game[_$_2aa1[4]][_$_2aa1[14]][1][_$_2aa1[4]][_$_2aa1[3]](_$_2aa1[5]);
    }
  }
}

[! [enter image description here] (https://i.sstatic.net/fzWxwTt6.jpg)] (https://i.sstatic.net/fzWxwTt6.jpg)
The js file is here: https://uronpen.cloud/decodeResult.js

Ask for the specific method or a tool. Ask for the specific method or a tool. Thank you.

Ask for the specific method or a tool.

How do I fix this unwanted button behavior in ReactJS

So I’m trying to conditionally switch between two html buttons in ReactJS base on wether the form is shown or not. Basically if the form is shown, show a submit button and if not shown, show a regular button to show the form.

This is the code that I have. (I’m using Antd’s button component but I also tried using the regular html button and had the same problem.

<div>
        {showForm ? (
          <Button
            loading={isUploading}
            htmlType="submit"
            form="videoForm"
            className={Styles.button}
          >
            {isUploading ? 'Uploading' : 'Upload Video'}
          </Button>
        ) : (
          <Button
            htmlType="button"
            onClick={() => setShowForm(true)}
            className={Styles.button}
          >
            {successMsg ? 'Upload Another Video' : 'Show Form'}
          </Button>
        )}
      </div>

The issue I’m having is that when the form is not shown and I click the Show Form button, the form shows correctly and the buttons switch, but the form submit event is triggering which is not what I expected or want.

Any ideas why? And how I can fix this issue? I also tried doing the following but got the same results.

<div>
        <Button
          loading={isUploading}
          htmlType={showForm ? 'submit' : 'button'}
          form="videoForm"
          className={Styles.button}
        >
          {showForm && (isUploading ? 'Uploading' : 'Upload Video')}
          {!showForm && (successMsg ? 'Upload Another Video' : 'Show Form')}
        </Button>
      </div>

Any help would be greatly appreciated.

SwiperJs: I’m displaying groups of 2 slides, they should be centered but I can’t even achieve it restraining the slides width

I am working with SwiperJS to create a slider that displays two slides per group, centered within the slider’s container. My current implementation results in the slides expanding to fill the entire available width of the container, which is not what I want. Ideally, I’d like the slides to occupy only part of the container’s width while remaining centered.

CodeSandbox Example:

Please refer to my CodeSandbox example here for a live demo of the issue.

Attempted Solutions:

  • I tried using flex, justify-content: center, and margin-inline: auto with width: fit-content for the slides.
  • I attempted to limit the swiper-container width.
  • None of these approaches have corrected the issue, suggesting that I might be missing something obvious. This should be simpler.

Here is what the current layout looks like:
enter image description here

Here is what I want to achieve (desired layout):
enter image description here

Note: the prev-arrow is not relevant, I’m just focused in achieve the centering.

Relavant code:

Javascript

$.getScript(
      "https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js",
      function () {
        new Swiper(".customSwiper", {
          grabCursor: true,
          slidesPerView: 2,
          centeredSlides: false,
          spaceBetween: 10,
          loop: false,  
          slidesPerGroup: 2,  
          navigation: {
            nextEl: '.swiper-button-next',
            prevEl: '.swiper-button-prev',
          },
        });
      }
    );

CSS:

/* swiper */
.swiper-slide {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  width: 100%;
  max-width: unset !important;
}
.swiper-container {
  width: 100vw;
  height: 100%;
  overflow: hidden;
  position: relative;
  background: #FFF;
  max-width: unset !important;
}
/* card being displayed */
.card {
  border-radius: 25px;
  background: #F8F8F8;
  box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.05);
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 5fr;
  max-width: 30em;
  width: fit-content;
  column-gap: 24px;
  }

Question:
How can I adjust my SwiperJS configuration or CSS to prevent the slides from stretching to fill the entire container width and instead center them as I’ve illustrated? Are there specific CSS properties or Swiper settings that could correct this behavior?

VueJs OnMount props generate “Expected Object, got Undefined ” warning

I’ve got the following component:

<template>
  <Grid :items="items" />
</template>

<script setup>
  import { ref, onMounted } from 'vue'
  import Grid from '@/components/Grid.vue'
  import { getData } from '@/services/getData'

  const items = ref()

  onMounted(async () => {
    items.value = await getData()
 })
</script>

The Grid component instance needs items to be populated in order to display data, but I need to run getData() to have the data ready. When I run this code I get a type check failed for prop "items". Expected Object, got Undefined warning.

It happens because when the file is first initiated items doesn’t have anything until getData() is finished. How can I have getData() run before the warning can show up?

How would I write data to an Audio File?

So I’ve been trying to make a DAW in the browser and I’ve got everything done except for exporting files. How would I go about writing data for an audio file?

I’ve tried utilizing the MediaRecorder API. I was expecting to be able to write data like that, but what actually happened was that it prompted me to use my microphone which is not what I was expecting.