Changing jinja template dynamically using Javascript

I am making a web application using flask and I am having issues solving a very specific problem.

In one of the pages, I am trying to use javascript in order to dynamically change part of the page to show different content. My problem is, that the new content I am trying to display resides in a different html file and I am trying to displaying using the jinja include template method. This is however not working as it is simply being recognized as text.

Some code to better showcase the issue:
When Initially loading the page, the div that has the content that I want updated looks like this:

<div id="graph-div">
    {% include "test_performance.html" %}
</div> 

and my javascript looks like this:

selection =  document.getElementById('category');

if (selection.value === 'Overall Tests & Failures') {
    document.getElementById('graph-div').innerHTML = '{% include "test_failures.html" %}';
} else {
    document.getElementById('graph-div').innerHTML = '{% include "test_failures.html" %}';
}

When initially loading the page, the content renders successfully, however after running the script, the following happens:

Image

Does anyone have any idea if doing what I am trying is actually possible (and how) or whether I need to approach this differently?

I have done some research and the only relevant post I found was this however, the solution marked as correct did not work for me.

Thanks,
George

AudioPlayerError: write EPIPE ytdl-core discordjs

I have been trying to make a music system to play songs in vcs using ytdl-core and ytsearcher while using discord js v13 for the bot. But I encounter a long error here it is:

node:events:504
      throw er; // Unhandled 'error' event
      ^

AudioPlayerError: write EPIPE
    at afterWriteDispatched (node:internal/stream_base_commons:160:15)
    at writevGeneric (node:internal/stream_base_commons:143:3)
    at Socket._writeGeneric (node:net:793:11)
    at Socket._writev (node:net:802:8)
    at doWrite (node:internal/streams/writable:406:12)
    at clearBuffer (node:internal/streams/writable:561:5)
    at onwrite (node:internal/streams/writable:461:7)
    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:106:10)
Emitted 'error' event on AudioPlayer instance at:
    at OggDemuxer.onStreamError (E:[email protected]:956:14)
    at Object.onceWrapper (node:events:646:26)
    at OggDemuxer.emit (node:events:538:35)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  resource: <ref *3> AudioResource {
    playStream: OggDemuxer {
      _readableState: ReadableState {
        objectMode: true,
        highWaterMark: 16,
        buffer: BufferList { head: null, tail: null, length: 0 },
        length: 0,
        pipes: [],
        flowing: false,
        ended: false,
        endEmitted: false,
        reading: true,
        constructed: true,
        sync: false,
        needReadable: true,
        emittedReadable: false,
        readableListening: true,
        resumeScheduled: false,
        errorEmitted: true,
        emitClose: true,
        autoDestroy: true,
        destroyed: true,
        errored: Error: write EPIPE
            at afterWriteDispatched (node:internal/stream_base_commons:160:15)
            at writevGeneric (node:internal/stream_base_commons:143:3)
            at Socket._writeGeneric (node:net:793:11)
            at Socket._writev (node:net:802:8)
            at doWrite (node:internal/streams/writable:406:12)
            at clearBuffer (node:internal/streams/writable:561:5)
            at onwrite (node:internal/streams/writable:461:7)
            at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:106:10) {
          errno: -4047,
          code: 'EPIPE',
          syscall: 'write'
        },
        closed: true,
        closeEmitted: false,
        defaultEncoding: 'utf8',
        awaitDrainWriters: null,
        multiAwaitDrain: false,
        readingMore: false,
        dataEmitted: false,
        decoder: null,
        encoding: null,
        [Symbol(kPaused)]: null
      },
      _events: [Object: null prototype] {
        prefinish: [Function: prefinish],
        close: [
          [Function (anonymous)],
          [Function: onclose],
          [Function: bound onceWrapper] {
            listener: [Function: onFailureCallback]
          }
        ],
        end: [
          [Function: onend],
          [Function: bound onceWrapper] {
            listener: [Function: onFailureCallback]
          }
        ],
        finish: [
          [Function: onfinish],
          [Function: bound onceWrapper] {
            listener: [Function: onFailureCallback]
          }
        ],
        error: [Function: onerror],
        readable: [
          [Function: bound onceWrapper] {
            listener: [Function (anonymous)]
          },
          [Function: bound onceWrapper] {
            listener: [Function: onReadableCallback]
          }
        ]
      },
      _eventsCount: 6,
      _maxListeners: undefined,
      _writableState: WritableState {
        objectMode: false,
        highWaterMark: 16384,
        finalCalled: false,
        needDrain: false,
        ending: false,
        ended: false,
        finished: false,
        destroyed: true,
        decodeStrings: true,
        defaultEncoding: 'utf8',
        length: 0,
        writing: false,
        corked: 0,
        sync: true,
        bufferProcessing: false,
        onwrite: [Function: bound onwrite],
        writecb: null,
        writelen: 0,
        afterWriteTickInfo: null,
        buffered: [],
        bufferedIndex: 0,
        allBuffers: true,
        allNoop: true,
        pendingcb: 0,
        constructed: true,
        prefinished: false,
        errorEmitted: true,
        emitClose: true,
        autoDestroy: true,
        errored: Error: write EPIPE
            at afterWriteDispatched (node:internal/stream_base_commons:160:15)
            at writevGeneric (node:internal/stream_base_commons:143:3)
            at Socket._writeGeneric (node:net:793:11)
            at Socket._writev (node:net:802:8)
            at doWrite (node:internal/streams/writable:406:12)
            at clearBuffer (node:internal/streams/writable:561:5)
            at onwrite (node:internal/streams/writable:461:7)
            at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:106:10) {
          errno: -4047,
          code: 'EPIPE',
          syscall: 'write'
        },
        closed: true,
        closeEmitted: false,
        [Symbol(kOnFinished)]: []
      },
      allowHalfOpen: true,
      _remainder: null,
      _head: null,
      _bitstream: null,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: null
    },
    edges: [
      <ref *1> {
        type: 'ffmpeg ogg',
        to: Node {
          edges: [ [Object], [Object], [Object] ],
          type: 'ogg/opus'
        },
        cost: 2,
        transformer: [Function: transformer],
        from: Node { edges: [ [Object], [Circular *1] ], type: 'arbitrary' }
      },
      <ref *2> {
        type: 'ogg/opus demuxer',
        to: Node { edges: [ [Object] ], type: 'opus' },
        cost: 1,
        transformer: [Function: transformer],
        from: Node {
          edges: [ [Circular *2], [Object], [Object] ],
          type: 'ogg/opus'
        }
      }
    ],
    metadata: null,
    volume: undefined,
    encoder: undefined,
    audioPlayer: <ref *4> AudioPlayer {
      _events: [Object: null prototype] { idle: [Function (anonymous)] },
      _eventsCount: 1,
      _maxListeners: undefined,
      _state: {
        status: 'buffering',
        resource: [Circular *3],
        onReadableCallback: [Function: onReadableCallback],
        onFailureCallback: [Function: onFailureCallback],
        onStreamError: [Function: onStreamError]
      },
      subscribers: [
        PlayerSubscription {
          connection: VoiceConnection {
            _events: [Object: null prototype] {},
            _eventsCount: 0,
            _maxListeners: undefined,
            rejoinAttempts: 0,
            _state: [Object],
            joinConfig: [Object],
            packets: [Object],
            receiver: [VoiceReceiver],
            debug: null,
            onNetworkingClose: [Function: bound onNetworkingClose],
            onNetworkingStateChange: [Function: bound onNetworkingStateChange],
            onNetworkingError: [Function: bound onNetworkingError],
            onNetworkingDebug: [Function: bound onNetworkingDebug],
            [Symbol(kCapture)]: false
          },
          player: [Circular *4]
      ],
      behaviors: { noSubscriber: 'pause', maxMissedFrames: 5 },
      debug: [Function (anonymous)],
      [Symbol(kCapture)]: false
    },
    playbackDuration: 0,
    started: false,
    silencePaddingFrames: 5,
    silenceRemaining: -1
  }
}

If anyone can help me here is my code:

const { SlashCommandBuilder } = require('@discordjs/builders');
const ytdl = require('ytdl-core');
const { joinVoiceChannel, createAudioResource, createAudioPlayer, AudioPlayerStatus } = require('@discordjs/voice');

const { YTSearcher } = require('ytsearcher');

const searcher = new YTSearcher({
    key: "myyoutubeapikey",
    revealKey: true
})

module.exports = {

    data: new SlashCommandBuilder()
        .setName('play')
        .setDescription('Permet de jouer de la musique dans votre salon vocal !')
        .addStringOption(option => option.setName('song').setDescription('Le nom de la musique / URL').setRequired(true)),

    async execute(interaction) {

        const song = interaction.options.getString('song');
        let vc = interaction.member.voice.channel;
        if(!vc){
            return interaction.reply({ content: ":warning: **- Vous devez être dans un salon vocal pour pouvoir jouer de la musique !**", ephemeral: true });
        }
        let result = await searcher.search(song, { type: "video" })
        console.log(result.first.url)

        const stream = ytdl(result.first.url, {
            filter: "audioonly",
        });

        const player = createAudioPlayer();
        const resource = createAudioResource(stream);

        const connections = joinVoiceChannel({
            channelId: vc.id,
            guildId: vc.guild.id,
            adapterCreator: vc.guild.voiceAdapterCreator,
        })

        player.play(resource);
        connections.subscribe(player);

        player.on(AudioPlayerStatus.Idle, () => {
            connections.destroy();
        });
    }

};

I tried a lot of things and I looked before making this post if someone already had the same problem (with the same context)

Send Javascript variables to PHP and validate it?

what’s the most secure-spoofless way to send Javascript variables to PHP and validate it?

I’m starting an application under
Index.PHP, it includes all the scripts including Call.JS

The Call.JS has a variable

var call = 'Some data';

How do I send ‘call’ to other PHP file validating that it came from Call.JS?

ReInit Swiper after an AJAX Call WordPress

I’m posting here because after many hours of research and some headache I didn’t find a solution to a problem with swiper JS in my website.

In my case, I have a WordPress website and I have an archive page with many listings each one with a slider (Swiper JS) that shows relevant images of the listing.

It works fine until I apply a filter to the page (Eg. select to show property with 4 beds) (so I think before I make an AJAX request).

The page reloads with AJAX and shows only relevant listings, the only problem is that the Swiper Slider doesn’t work anymore, in fact, I cannot slide it.

By logic, I think I need to reinitialize Swiper after every AJAX call but as I’m not so good at AJAX I’m kind of wondering if anyone can point me into the right direction. Thank you very much.

My Swiper Code:

    jQuery(document).ready(function() {
const swiper = new Swiper('.swiper', {
  // Optional parameters
    direction: 'horizontal',
    effect: 'slide',
    speed: 150,
    loop: true,
    observer: true,

  // Navigation arrows
  navigation: {
    nextEl: '.swiper-button-next',
    prevEl: '.swiper-button-prev',
  },
    
      pagination: {
    el: '.swiper-pagination',
  },
});

});

How can I Change Color of DataTable Title & Row Text

I want to change the Color of The Text of The DataTable Title[Name,Email,Phone] & and The DataTable Row[Hassane1,[email protected],0688888888], I use color: 'red' but it’s not Working I need Some Help

This the Code:

import React, { useState } from 'react';
import { StyleSheet, SafeAreaView, ScrollView,Text, View, Modal } from 'react-native';
import { DataTable } from 'react-native-paper';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';

import COLORS from '../src/conts/colors';
import Button from '../src/views/components/Button';


const List = ({navigation}) => {



  const data = [
    {id:1,name:"Hassane1",phone:"068888188888",email:"[email protected]"},
    {id:2,name:"Hassane2",phone:"068888888288",email:"[email protected]"},
    {id:3,name:"Hassane3",phone:"068888388888",email:"[email protected]"},
    {id:4,name:"Hassane4",phone:"068888388888",email:"[email protected]"},
    {id:5,name:"Hassane5",phone:"068888388888",email:"[email protected]"},
    {id:6,name:"Hassane6",phone:"068888388888",email:"[email protected]"},
    {id:7,name:"Hassane7",phone:"068888388888",email:"[email protected]"},
  ]


  const renderList = data.map((item)=>{

    return(

      <DataTable.Row style={styles.tableRow} key={item.id}>
            <DataTable.Cell onPress={() => navigation.navigate("Edit",{item})} >{item.name}</DataTable.Cell>
            <DataTable.Cell style={{color: COLORS.red}}>{item.email}</DataTable.Cell>
            <DataTable.Cell>{item.phone}</DataTable.Cell>
        </DataTable.Row>
    )
  })
return (
  <SafeAreaView style={{ flex: 1}}>
  <ScrollView
    contentContainerStyle={{paddingTop: 50, paddingHorizontal: 20}}>
    <Text style={{color: COLORS.black, fontSize: 40, fontWeight: 'bold', fontFamily: 'Roboto',textAlign: 'center'}}>
      List of Companies
    </Text>
    <Text style={{color: COLORS.grey, fontSize: 18, marginVertical: 10, fontFamily: 'Roboto', textAlign: 'center'}}>
      Check Our Companies Details
    </Text>
  <DataTable style={styles.container}   >
  <DataTable.Header style={styles.tableHeader}  >
    <DataTable.Title style={{color: COLORS.red}}>Name</DataTable.Title>
    <DataTable.Title>Email</DataTable.Title>
    <DataTable.Title>Phone</DataTable.Title>
  </DataTable.Header>
  </DataTable>
    {renderList}
  </ScrollView>
  </SafeAreaView>


);
};

export default List;

const styles = StyleSheet.create({
container: {
    padding: 10,
  color: 'red',
},
tableHeader: {
  color: 'red',
},
tableRow: {
  color: 'red',
},

});

This is The Result:
enter image description here

Cordova overwrites Framework 7 custom JS and HTML?

I have followed the procedures outlined here in the Framework7 documentation to build a PWA with cordova. I’m on Ubuntu. Something happens when I cd my projects and run cordova in the browser. The cordova.js overwrites any html or custom js and I’m stuck here. If I remove cordova.js from the project, then I can use custom F7 js and css. Thing is, I’m building a Hybrid app for Android and Apple so I do need the cordova plugins and without cordova.js well this wont happen. Is this a catch 22 what’s going on? I’ve built hybrid cordova apps before and this never happened.

structure of folders
enter image description here

index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
<meta name="color-scheme" content="light dark">
<meta name="apple-mobile-web-app-capable" content="yes">
<!--app title-->
<title>MyApp | F7 Cordova App </title>
<!-- Path to Framework7 Library Bundle CSS -->
<link rel="stylesheet" href="css/framework7.bundle.min.css">
<!-- Path to Framework7 Library Bundle JS-->
<script type="text/javascript" src="js/framework7.bundle.min.js"></script>
<!--custom stylesheet-->
<link rel="stylesheet" href="css/app.css">
<!--JQUERY UI CSS-->
<link rel="stylesheet" href="css/jquery-ui.css">
<!--JQUERY-->
<script src="js/jquery-3.6.0.min.js"></script>
<!--JQUERY UI JS-->
<script src="js/jquery-ui.js" type="text/javascript"></script>

</head>
<body>
<!-- App root element -->
<div id="app">
<!-- Your main view, should have "view-main" class -->
<div class="view view-main">
<!-- Initial Page, "data-name" contains page name -->
<div data-name="home" class="page">

<!-- Top Navbar -->
<div class="navbar">
<div class="navbar-bg"></div>
<div class="navbar-inner">
<div class="title">Awesome App</div>
</div>
</div>

<!-- Bottom Toolbar -->
<div class="toolbar toolbar-bottom">
<div class="toolbar-inner">
<!-- Toolbar links -->
<a href="#" class="link">Link 1</a>
<a href="#" class="link">Link 2</a>
</div>
</div>

<!-- Scrollable page content -->
<div class="page-content">
<p>Page content goes here</p>
<!-- Link to another page -->
<a href="/about/">About app</a>
</div>
</div>
</div>
</div>
</body>
</html>
<!--scripts-->
<script src="cordova.js"></script>-->
<script src="js/app.js"></script>

href retrieval with cheerio/axios

I have a html file that looks something like this:

<div class="col-md-8">
  <ul class="list-inline mb-0">
     <li class="list-inline-item mr-3">
       <a class="link-hover-secondary" data-placement="top" data-toggle="tooltip" data-original-title="Twitter: https://www.twitter.com/EY3K0N" rel="nofollow" target="_blank" href="https://www.twitter.com/EY3K0N"><span class="fab fa-twitter"></span></a></li>
     <li class="list-inline-item mr-3">
       <a class="link-hover-secondary" data-placement="top" data-toggle="tooltip" data-original-title="Discord: https://discord.gg/ey3k0n" rel="nofollow" target="_blank" href="https://discord.gg/ey3k0n"><span class="fab fa-discord"></span></a></li>
     <li class="list-inline-item mr-3">
       <a class="link-hover-secondary" data-placement="top" data-toggle="tooltip" data-original-title="Opensea: https://opensea.io/collection/ey3k0n-first-edition" rel="nofollow" target="_blank" href="https://opensea.io/collection/ey3k0n-first-edition/"><img id="opensea_logo" src="/images/opensea.svg" class="mt-n3px" width="15"></a></li>
  </ul>
</div>

I need to get each of the hrefs within the ul => li

I currently have:

const cheerio = require("cheerio");
const axios = require("axios");

axios.get("https://etherscan.io/token/0x1c410e4c1701f88a2a504f4506251624e8166419").then(res => {
   const $ = cheerio.load(res.data);

   $('li.list-inline mb-0').each( (index, element) => {
        let website = $(element)
            .find('a')
            .attr('href');
        console.log();
    })
})

link is https://etherscan.io/token/0x1c410e4c1701f88a2a504f4506251624e8166419

Typescipt evaluates conditional types incorrectly

I have a very primitive code that for some reason gives a type error.

type ConfigEntry = {
  name?: string,
  value?: string
}

function parser1(c: ConfigEntry): Record<string, string> {
  const name = c.name;
  const value = c.value;
  return { name: value }; // fine, error since name can be undefined
}

function parser2(c: ConfigEntry): Record<string, string> | undefined {
  const name = c.name;
  const value = c.value;
  if (name === undefined) return undefined;
  else return { name: value }; // compiler still argues that name can be undefined
  // but in any circumstances it is not
}

If I understand TS correctly, compiler should examine conditions and evaluate types accordingly.
Also none of the other conditional expressions known to me work as well.
Example is here

How to access/flatten array in nested array?

I have an array made up of 7 sub-arrays, like this:

myArray = [Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2)]

when expanded:

0: [‘name1’, Array(0)]
1: [‘name2’, Array(0)]
2: [‘name3’, Array(0)]
3: [‘name4’, Array(0)]
4: [‘name5’, Array(0)]
5: [‘name6’, Array(0)]
6: [‘name7’, Array(0)]

Zooming into this first sub-array:

[‘name1’, Array(0)]

when expanded:

0: ‘name1’
1: []

Element [1] of these sub-arrays gets filled with a click on the app.

The problem is, when I try to access myArray[0][1] or myArray[0][1][0], instead of getting ‘undefined’, the app crashes.

How can I successfully access this sub-sub-array?

Or, alternatively, how can I flatten these sub-arrays into:

[‘name1’, []]

Please help! Thank you!!

Move from CommonJS to ESM’s export/import

It might has been fully discussed but I can’t find a perfect answer from either here or here.

Basically

  • CommonJS uses the require('./xx') syntax, while
  • ESM uses the import {stuff} from './xx' syntax

Here is how I’ve been doing the require when using CommonJS

  • require('apackage') or
  • require('./myfile')

I.e., I don’t need to specify their extensions for either case.

But moving to ESM import, the import {stuff} from './myfile' is giving me the error of:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module

In here it shows how to move from CommonJS and do ESM import:

from

const colors = require("colors");         // Obj w/ all export fields
const { red, blue } = require("colors");  // Select fields from export obj

to

import colors from "colors";          // _Only_ `default` export (`{ green }`)
import { red, blue } from "colors";   // Other named exports

But is it possible for me not to specify their extensions for my own files as well? Otherwise,

  • it will be inconsistent between importing ‘apackage` or ‘./myfile’,
  • lots of unnecessary work for me to add their extensions to my current imports
  • and need to force me to change again if I decided to switch their extensions between js and mjs,

How to make object dynamic so that Any String I put into that key will be returned?

I know the question is confusing
So the problem here is that I am retriving the data into dropdown by map method, that data comes from backend.

And then here is a Object that I am creating on front-end side of application that have field things in it.

 const [dataType, setDataType] = useState('none')

 const addGraph = (thisData) => {

    const graphToAdd = apiResponse.find(curr => curr.name === thisData)
    const newGraph = {
      type: graphType,
      labels: graphToAdd.labels,
      things: (dataType === 'age' ? graphToAdd.age : (dataType === 'stipend' ?  graphToAdd.stipend : graphToAdd.attendance))
    }
    setGraphs((previous) => [...previous, newGraph])
    
  }

<!-- begin snippet: js hide: false console: true babel: false -->
   <label htmlFor="dataTypes" style={{'fontWeight':'bold'}}>Data Type:</label>
    <select className='py-2 px-3 rounded-sm mt-2 border-3 border-black' name="dataTypes" id="dataTypes" onChange={(e) => setDataType(e.target.value)}>
      {
        objectKey.map((curr) => (
          <option key={curr} className='py-2 px-3 rounded-sm mt-2 border-3 ' value={curr}>{curr}</option>
        ))
      }  
    </select>

and here is the code for dropdown.
I really don’t have any idea how should I make”things” key in the object so that for any value that I select I should exactly retrive the data from graph to add.
All the data map into the dropdown is sure present in graphToAdd in key: value pair.
Also sorry If I am not explaining it correctly.

if data contains other keys then those other keys were mapped into this dropdown.

What should be an approach to do this ?

Typescript: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`

I’ve an npm command line application that i’ve built not so long ago and it worked fine. Now that i’ve updated it, and due to changes in the versions of typescript over the period, i’m getting an error when i want to run this package which says:

Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.

Here is the package.json file:

{
  "name": "initialiseur",
  "version": "4.0.4",
  "main": "src index.ts",
  "author": "@crispengari",
  "license": "MIT",
  "bin": "src/index.ts",
  "description": "THIS IS A BOILER PLATE THAT INITIALIZE A NODE EXPRESS BACKEND FOR TYPESCRIPT AND JAVASCRIPT",
  "scripts": {
    "watch": "tsc -w",
    "start": "ts-node src/index.ts",
    "dev": "nodemon dist/index.ts",
    "start:fast": "tsnd --respawn src/index.ts"
  },
  "dependencies": {
    "@types/inquirer": "^7.3.3",
    "@types/node": "^17.0.42",
    "@types/npm": "^7.19.0",
    "chalk": "^4.1.2",
    "cors": "^2.8.5",
    "cross-fetch": "^3.1.5",
    "dotenv": "^10.0.0",
    "inquirer": "^8.1.2",
    "node-fetch": "^3.2.6",
    "octokit": "^1.7.2",
    "ts-node": "^10.8.1",
    "typescript": "^4.6.5"
  },
  "devDependencies": {
    "@types/node-fetch": "^2.6.1",
    "nodemon": "^2.0.12",
    "ts-node-dev": "^2.0.0"
  },
  "bugs": {
    "url": "https://github.com/CrispenGari/initialiseur/issues"
  },
  "homepage": "https://github.com/CrispenGari/initialiseur#readme",
  "keywords": [
    "node.ts",
    "node.js",
    "typescript",
    "ts",
    "nodejs-backend",
    "javascript",
    "js",
    "express",
    "backend"
  ]
}

When i’m testing it locally by running:

npm start

# or 
yarn start

Everything is working fine, but after publishing it to npm to start it i run the following command:

npx initialiseur

Then I’m getting the error from a command line. The whole error is as follows:

C:UserscrispAppDataRoamingnpmnode_modulesinitialiseurnode_modulestypescriptlibtypescript.js:42536
        ts.Debug.assert(typeof typeReferenceDirectiveName === "string", "Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.");
                 ^
Error: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.
    at Object.resolveTypeReferenceDirective (C:UserscrispAppDataRoamingnpmnode_modulesinitialiseurnode_modulestypescriptlibtypescript.js:42536:18)
    at C:UserscrispAppDataRoamingnpmnode_modulests-nodesrcresolver-functions.ts:131:51
    at Array.map (<anonymous>)
    at Object.resolveTypeReferenceDirectives (C:UserscrispAppDataRoamingnpmnode_modulests-nodesrcresolver-functions.ts:130:31)
    at actualResolveTypeReferenceDirectiveNamesWorker (C:UserscrispAppDataRoamingnpmnode_modulesinitialiseurnode_modulestypescriptlibtypescript.js:116673:163)
    at resolveTypeReferenceDirectiveNamesWorker (C:UserscrispAppDataRoamingnpmnode_modulesinitialiseurnode_modulestypescriptlibtypescript.js:116973:26)
    at processTypeReferenceDirectives (C:UserscrispAppDataRoamingnpmnode_modulesinitialiseurnode_modulestypescriptlibtypescript.js:118455:31)
    at findSourceFileWorker (C:UserscrispAppDataRoamingnpmnode_modulesinitialiseurnode_modulestypescriptlibtypescript.js:118340:21)
    at findSourceFile (C:UserscrispAppDataRoamingnpmnode_modulesinitialiseurnode_modulestypescriptlibtypescript.js:118195:26)
    at processImportedModules (C:UserscrispAppDataRoamingnpmnode_modulesinitialiseurnode_modulestypescriptlibtypescript.js:118601:25)

From the above error i can tell that the problem maybe comming from typescript, I’v tried changing version of typescript but still it’s not working. In my src/index.ts it looks as follows:


#!/usr/bin/env ts-node
import path from "path";
import inquirer from "inquirer";
import { writeFile, readFile } from "fs/promises";

....


Why is document.getElementById() returing null when ran through a for loop? [duplicate]

I’m developing a web-based game and I’ve discovered a problem with this code:

document.getElementById("g").onload = function () { // #g is the body
    for (let i = 0; i < $h; i++) { // $h = 2
        for (let j = 0; i < $w; i++) { // $w = 5
            let l = String.fromCharCode(97 + i);
            document.getElementById(l+toString(j)).onclick = $add;
        }
    }
};

Basically, the code is supposed to run through elements with an ID of a1,a2...a5,b1,b2...b5 and assign the void $add to onclick of each element.
For some very strange reason, it’s giving me this error:

Uncaught TypeError: can’t access property “onclick”, document.getElementById(…) is null

I’ve tried so many things that I can’t even list them here without it looking like a 2-year-old toddler who has the mental capacity of a half-eaten blackberry wrote it.

I am like the yogurt that’s been sitting in my fridge for about 2 months at this language.