Deno in Jupyter: Can’t Run HTTP Server Consistently

I have been delving into some Javascript web development with Deno, and am trying to get it to work with Jupyter notebooks on Windows 10. I am overall familiar with the basics of Html, CSS, and Javascript, but can’t seem to be able to create a basic HTTP page.

The first time I run the below snippet, the server does not open in a new tab in http://localhost:80001/ (it keeps loading), and on the second run the same code (rerunning the same cell), the server loads the right code in the new tab but with errors and gives the output below.

I feel I am missing something basic, would anyone have any insight what it is?

\ Basic server I am trying to run.
function handler(_req: Request): Response {
  return new Response("Hello, World!");
}

\ Output after I run the above code twice.
Stack trace:
AddrInUse: Only one usage of each socket address (protocol/network address/port) is normally permitted. (os error 10048)
    at listen (ext:deno_net/01_net.js:520:35)
    at Object.serve (ext:deno_http/00_serve.js:592:16)
    at <anonymous>:4:6
Deno.serve({ port: 80001 }, handler);

Second call to requestFullscreen is denied in Firefox

I am trying to create a simple HTML file that I can use to make one half of my 32:9 widescreen dark (e.g. while watching a video).

I have created this document that works pretty well:

<!DOCTYPE html>
<html>
    <head>
        <title>&nbsp;</title>
        <meta charset="utf-8">
        <style>
* { background-color: black; height: 100%; margin: 0; padding: 0; }
.no-cursor { cursor: none; }
        </style>
        <script type="text/javascript">
const MOTION_TIMEOUT = 500;
const FREEZE_TIMEOUT = 1000;
const NO_CURSOR_CLASS = "no-cursor";
var motionTimer, unfreezeTimer, hidden, frozen;
function tryOpenFullscreen(elem) {
    let requestFullscreen = elem.requestFullscreen || elem.mozRequestFullScreen || elem.webkitRequestFullscreen || elem.msRequestFullscreen;

    if (requestFullscreen) {
        try {
            requestFullscreen.call(elem);
        } catch (error) {
            console.error("Failed to open fullscreen", error);
        }
    } else {
        console.error("Fullscreen not supported");
    }
}
function mouseNotMoved() {
    window.clearTimeout(motionTimer);
    hide();
}
function mouseMoved() {
    if (!frozen) {
        window.clearTimeout(motionTimer);
        show();
        motionTimer = window.setTimeout(mouseNotMoved, MOTION_TIMEOUT);
    }
}
function isInFullscreen() {
    const element = document.fullscreenElement || document.webkitFullscreenElement || document.msFullscreenElement;
    return element !== undefined && element !== null;
}
function toggleFullscreen() {
    // Toggling fullscreen will trigger mousemove event,
    // so we need to freeze the cursor motion detection for a short time
    window.clearTimeout(unfreezeTimer);
    freeze();
    unfreezeTimer = window.setTimeout(unfreeze, FREEZE_TIMEOUT);

    if (isInFullscreen()) {
        document.exitFullscreen();
    } else {
        tryOpenFullscreen(document.body);
    }
}
function keyPress(event) {
    if (event.key === "Escape") {
        // Exit fullscreen when pressing Escape
        if (isInFullscreen()) {
            toggleFullscreen();
        }
    } else if (event.key === "f") {
        toggleFullscreen();
    } else if (event.key === "F11") {
        // Prevent browser from going fullscreen by pressing F11
        // Using F11 to exit fullscreen is allowed
        if (!isInFullscreen()) {
            event.preventDefault();
            toggleFullscreen();
        }
    }
}
function hide() {
    document.body.classList.add(NO_CURSOR_CLASS);
    hidden = true;
}
function show() {
    document.body.classList.remove(NO_CURSOR_CLASS);
    hidden = false;
}
function freeze() {
    frozen = true;
}
function unfreeze() {
    frozen = false;
}
function init() {
    hidden = true;
    frozen = false;
    document.body.addEventListener("mousemove", mouseMoved);
    document.body.addEventListener("dblclick", toggleFullscreen);
    window.addEventListener("keydown", keyPress);
    motionTimer = window.setTimeout(mouseNotMoved, MOTION_TIMEOUT);
}
window.addEventListener("load", init);
        </script>
    </head>
    <body>
    </body>
</html>

It’s basically a blank black page with some setTimeout code to hide the cursor when that doesn’t move for a bit. And to make the whole screen black, I have a method toggleFullscreen that determines whether it needs to request or exit the fullscreen, and then calls uses the available requestFullscreen method on the document.body element, or document.exitFullscreen().

toggleFullscreen is called either as the dblclick event handler, or from within an event handler for the keydown event if the F key was pressed. All this works absolutely fine, I can press F as often as I want to toggle back and forth.

But now I’m having trouble with adding the last “feature”: The default F11 fullscreen mode will reveal a flyout navigation bar when the mouse moves to the top screen border, which is unwanted behavior for my purposes. Hence I would like to use my own toggleFullscreen for entering. As suggested here I am calling event.preventDefault() first, and then toggleFullscreen.

But here it becomes strange: entering fullscreen this way works, but not if I just left fullscreen with F11:

  • I can intercept the first F11 keypress, prevent the browser fullscreen, and go into DOM fullscreen instead.
  • I also intercept the second F11, but let it exit fullscreen by native means, which works just fine, too.
  • When I press F11 for the third time, requestFullscreen throws an error “Fullscreen request denied”.

The error comes with a warning “Request for full-screen was denied because Element.mozRequestFullScreen() was not called from inside a short running user-generated event handler.” This question talks about this error, but I’m not having a 1-second problem I think – the code should take mere milliseconds to get to the request.

What puzzles me is that the keydown event handler should tick all the boxes for “short running user-generated event handler” (event.isTrusted is true for the F11 event that will cause the throw).

I did some testing and found that requesting fullscreen through F11 fails if and only if the previous user-generated event was “exit fullscreen through F11“:

My keydown event handler

  • works indefinitely when using only F to enter and exit
  • works indefinitely when using F11 to enter but F to exit
  • doesn’t work when using F to enter and F11 to exit and then F11 to enter again
  • works indefinitely using just F11 to enter and exit when I click once before using F11 to enter

I’ve tried using document.focus() and document.click() in an attempt to mimic the effect of the mouse click, but to no avail. I also tried using preventDefault + toggleFullscreen for F11 enter and exit, but that doesn’t make a difference, either.

The document works in Edge and Chrome, but as Firefox is my default browser, I’d like to fix it for this.

Iframe does not render tables with print()

I am trying to render html with tables in an iframe to create a pdf. When I call the function print() on iframe contentWindow it renders all the content in the html correctly except tables.

export async function exportToPDF(
  title: string,
  content: string
): Promise<boolean> {
  if (!content) return false;

  return new Promise<boolean>((resolve) => {
    const iframe = document.createElement("iframe");

    iframe.srcdoc = content;
    iframe.style.position = "fixed";
    iframe.style.right = "0";
    iframe.style.bottom = "0";
    iframe.style.width = "0";
    iframe.style.height = "0";
    iframe.style.border = "0";
    iframe.loading = "eager";

    iframe.onload = async () => {
      if (!iframe.contentWindow) return;
      if (iframe.contentDocument) iframe.contentDocument.title = title;
      iframe.contentWindow.onbeforeunload = () => closePrint(false);
      iframe.contentWindow.onafterprint = () => closePrint(true);

      iframe.contentWindow.print();
    };

    function closePrint(result: boolean) {
      document.body.removeChild(iframe);
      resolve(result);
    }

    document.body.appendChild(iframe);
  });
}

I looked at the html given to srcDoc and it has all the table tags. So tables are not gone but they just don’t render. I have tried it on chrome and firefox but the result is same.

Range slider in React Native

I’m trying to figure out how to add those ‘prefixes’. Do I need to handle it through styling manually, or is there a specific prop I should be using? I’m still getting the hang of it, so any guidance would be greatly appreciated

this is the figma design that i want to develop

I’am using ‘@ptomasroos/react-native-multi-slider’ library

And this is the component of the range slider:

import MultiSlider from '@ptomasroos/react-native-multi-slider';
import React, { useEffect, useState } from 'react';
import { Dimensions, StyleSheet, Text, View } from 'react-native';

export default function RangeNumber({ onChange}) {
    const [value, setValue] = useState({ values: [0, 800000] });
    const multiSliderValuesChange = (values) => {
        setValue({
            values,
        });
    };
    useEffect(() => {
        onChange(value)
    }, [value])
    return (
        <View style={styles.container}>
            <MultiSlider
                values={[value.values[0], value.values[1]]}
                sliderLength={Dimensions.get('window').width * 0.83}
                selectedStyle={{ backgroundColor: Colors.DeepGreen }}
                // containerStyle={{
                //     justifyContent: 'center',
                //     alignItems: 'center'
                // }}
                onValuesChange={multiSliderValuesChange}
                markerStyle={{
                    height: 30,
                    width: 30,
                    borderWidth: 7,
                    borderRadius: 50,
                    backgroundColor: Colors.DeepGreen,
                    borderColor: Colors.white,
                }}
                trackStyle={{
                    height: 10,
                }}
                unselectedStyle={{
                    borderRadius: 10
                }}
                min={0}
                markerOffsetY={5}
                max={800000}
                step={100}

            />
            <View style={styles.rangeText}>
                <Text style={styles.textColor}>{value.values[0]} K</Text>
                <Text style={styles.text}> - </Text>
                <Text style={styles.textColor}>{value.values[1]} K</Text>
            </View>
        </View>
    );
}

const styles = StyleSheet.create({
    container: {
        alignItems: 'flex-start',
        justifyContent: 'center',
        paddingHorizontal: 15,
        paddingVertical: 5,

    },
    title: {
        fontSize: 16,
        fontFamily: FONTS.PoppinsSemiBold
    },
    text: {
        color: '#FFFFFF',
        fontSize: 20,
        marginHorizontal: 10,
        marginTop: 10
    },
    rangeText: {
        flexDirection: 'row',
        alignItems: 'center',
        justifyContent: 'center',
        marginTop: -20
    },
    textColor: {
        color: '#DBDBDB',
        fontSize: 20
    }
});

this is the slider i got

issue with datatables updating a row

I have this function for updating the row in my datatables, but instead of updating, it is adding a row and also throwing an error on the node where i have to apply the class

function reqUpdate(dataValues, type,rowID) {
  // It's an AJAX method using jQuery
  dataValues.dformat = $('.timesheet_application').attr('data-format').toUpperCase();
  $.ajax({
    url: 'data.cfm?section=uupdate',
    type: 'POST',
    data : dataValues,
    success: function(response) {
      var _response = JSON.parse(response);
      var table = $('#tblData').DataTable(); // Get the DataTable instance
      $.each(_response.data, function(index, item) {
        // Now you can access each property of the item object
         table.row.add({
          "DT_RowId": "_" + index,
          "Icon": item.Icon,
          "Employee": item.Employee,
          "Type": item.Type,
          "viewIcon": item.viewIcon
        }).draw();
      });
      var row = table.row('#' + rowID); // Get the row
      row.node().classList.add(type == 'reject' ? 'newTabClass' : 'newClass'); -- error here main.js:1328 Uncaught TypeError: Cannot read properties of null (reading 'classList')
      setTimeout(function(){
        row.node().classList.remove(type == 'reject' ? 'newTabClass' : 'newClass'); 
      }, 15000);     
    },
    error: function(err) {
      customSwal('Error',err);
    }
  });
}

how can i make te update instead of add, please guide

How do I make my Backend (Springboot) and Frontend (React) communicate?

Until now, I have only done backend developing with Java / Springboot. I decided to do my own small project with a seperated front- and backend.
I am very unsure on how to connect both, lets set an easy example:

  1. User does some input data which gets through my html form
  2. My website processes this data, manipulates it, saves it in the database and shows it back to the user

My first thought on how to implement that is this:
the user input going through the html form will do (with an Action) a POST Request to my Springboot Controller, which then gets manipulated and saved by my applicationservice. At the same time, with Javascript i add an eventlistener to that form and whenever the button is clicked, it would make an GET Request to my Spring RestController and fetch the manipulated data, and then puts in to the HTML.
like this
Is this a (or even the) correct approach on how to make my front and backend work together?
I still have 1 issue with this approach: If the manipulating and saving of the input data takes more time than the GET Request being made silmutaniously by my Javascript code, it would be really bad.

React – Using useState to delete and re-render array of images

I’ve recently started learning React and I want try using useState. I’m having an issue where the page is not rendering after image has been clicked and deleted from the array of image links.

Here is my code

import data from './assets/data/images.json'
import { useState } from 'react'

function App() {

  var defaultList = Object.values(data)
  const [image, removeImage] = useState(defaultList)
  
  const callback = (key) => {
    console.log("removed image: ", defaultList[key])
    delete defaultList[key]
    removeImage(defaultList)
  }

  return (
    <div className={styles.App}>
      
      <div className={styles.ImageExamples}>
        {
          image.map((v, k) => {
            return <a onClick={() => callback(k)}><img src={v}/></a>
          })
        }
      </div>
    </div>
  );
}

To test this, you will need images.json

{
    "0": "https://images.unsplash.com/photo-1696399744120-da551393c12f?w=600&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxjb2xsZWN0aW9uLXBhZ2V8Nnw0NjU0NzMxfHxlbnwwfHx8fHw%3D",
    "1": "https://images.unsplash.com/photo-1622532824228-e1dffce3f265?w=600&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxjb2xsZWN0aW9uLXBhZ2V8M3wxNjYzMjQwfHxlbnwwfHx8fHw%3D",
    "2": "https://images.unsplash.com/photo-1542652735873-fb2825bac6e2?w=600&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxjb2xsZWN0aW9uLXBhZ2V8OXwxNjYzMjQwfHxlbnwwfHx8fHw%3D",
    "3": "https://images.unsplash.com/photo-1472656877636-35a4bb852385?w=600&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxjb2xsZWN0aW9uLXBhZ2V8MjB8MTU4ODI1fHxlbnwwfHx8fHw%3D",
    "4": "https://images.unsplash.com/photo-1614364655846-cd8087a5b38b?w=600&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxjb2xsZWN0aW9uLXBhZ2V8NDh8MTU4ODI1fHxlbnwwfHx8fHw%3D"
}

When I click on the images, the console shows that the image has been deleted from the array, however the useState doesn’t rerender the page once the image has been clicked. The changes only show up, after I made some changes to the code, saved it, removed the changes and saved it again.

Clients website continuously reloading (but only for a few people) once pixel placed on GTM – any way to capture why?

I’ve created a javascript file that gathers some information from the browser – IP address, url, screen dimensions, etc… – and sends that information off to my server to use that information to create a dynamic offering for them.

I have this code installed on dozens of client sites all across the country via a Google Tag Manager.

However, I have one client who has 3 separate locations – and thus 3 separate websites – where the script causes the site to continuously reload.

For testing, we have:

  1. Asked them to remove all other GTMs except for ours and the problem persists.
  2. Keep all other GTMs but ours – and the problem no longer persists
  3. Try in another browser other than Chrome and the problem no longer persists
  4. Try in incognito within chrome and the problem persists
  5. Try with a VPN on and the problem no longer persists
  6. Try to visit another client of mine and they do not experience the problem on other sites

Basically – the problem only exists in chrome (both incognito and non-incognito) but only on their specific sites and only when they’re NOT on their VPN.

In order to put a bandaid on the issue, I’ve put their IP address on a blacklist so the script doesn’t load from their computer – but now they’re getting complaints from customers that it’s happening to them too.

Is there any javascript I can add to my container that loads the “main” script that will listen for a refresh and, once found, will post and AJAX request to my server with information pertaining to why the site was refreshed?

I’m sure my code is conflicting with another script on the site, but I can’t debug the issue since it’s not happening locally.

Here is the container that loads the main script if the IP is not blacklisted:

// Ips are made up for stack overflow
let wd_blacklistedIPs = ['147.298.45.43','132.84.44.642','67.221.60.17','122.58.249.330'];

function wd_isBlacklisted(ip) {
    return wd_blacklistedIPs.includes(ip);
}

function wd_loadScript() {
    let script = document.createElement('script');
    script.src = 'https://server.mydomain.com/codeThatGeneratesOverlay.js';
    console.log("Loading overlay script");
    // Add the script to the body
    document.body.appendChild(script);
    console.log("Overlay script loaded");
}

// Get user's IP address
let wd_userIPAddress;

fetch('https://server.mydomain.com/getIP.php')
        .then(response => response.json())
        .then(data => {
            wd_userIPAddress = data.ip;
            if (!wd_isBlacklisted(wd_userIPAddress)) {
                wd_loadScript();
            } else {
                console.log('Not Loading Overlay');
            }
        })
        .catch(error => console.error('Error fetching IP address: ', error));

Like I said, the blacklisting is working, and it’s the “codeThatGeneratesOverlay.js” that seems to be causing the problem – but it’s working on dozens of other sites without issue… The only thing I can think of now to do to troubleshoot is to attempt to see WHY the site is refreshing via an ajax POST to my server.

Why is my Firestore query returning no matches even when there is a clear match?

Database Structure

I have a collection of user’s infos and I want to return only documents matching with the user’s tag if any. Problem is without a query filter I can get the collection and any document. Once I add a query filter, it doesn’t matter the equality checker (==, !=), I use it returns nothing. I’m using ReactJS Firestore SDK Library.

This is my code so far, what am I missing?

///InitFirebase.js
import { getFirestore } from "firebase/firestore";
export const firestore = getFirestore();

///EditProfile/Body.js
import { firestore } from "../../scripts/InitFirebase";
import { query, collection, getDocs, where } from "firebase/firestore";

const handleQuery = async() => {

const ref = collection(firestore, "user-info");
const q = query(ref, where("myTag", "==", "hal_top_g"));
const querySnapshot = await getDocs(q);

querySnapshot.forEach((doc) => {
console.log(doc.id, " => ", doc.data());
});
}

Returning both HTML and data (metadata?) from a React component

I am working on an app that will automatically populate a bracket based off of some data.

Currently I have a React component which displays the matchup between two teams. This component could calculate the predicted winner of the match, however I need to access that predicted winner elsewhere in my app.

So my component is very simple right now.

export const BracketMatchup = ({ highseed, lowseed, round }) => {
  return (
    <div
      className={style.bracketMatchup}
      style={{ height: `calc(75px * ${round})` }}
    >
      <div className={style.highSeed}>{highseed?.name}</div>
      <div className={style.lowSeed}>{lowseed?.name}</div>
    </div>
  );
};

The component takes a couple of seeds and just displays the information.

Pulling the app together I am stacking multiple instances of the BracketMatchup component.

    <div className={styles.bracket}>
      <div className={styles.bracketColumn}>
        <BracketMatchup
          highseed={getTeam("Kansas")}
          lowseed={getTeam("ISU")}
          round={1}
          id="1"
        />
        <BracketMatchup
          highseed={getTeam("TCU")}
          lowseed={getTeam("BYU")}
          round={1}
          id="2"
        />
      </div>
      <div
        className={styles.bracketColumn}
        style={{ marginTop: "calc(75px / 2)" }}
      >
        <BracketMatchup round={2} id="3"/>
      </div>
    </div>

Now the problem I am having is that my last BracketMatchup component should use the projected winners from the previous two components. Ideally the BracketMatchup with id=3 would take the winners from BracketMatchup with id=1 and id=2 however I am not sure how to return that data from the BracketMatchup

Code Sandbox

Javascript FETCH to display digital signature in my form

I keep trying here, new to JavaScript, if you can help me to figure this out. Thank you.

I have this code:

var docDescription = 'Please sign wire transfer request';
var reqUrl = 'http://localhost:12001/SigCaptureWait?ResponseType=API&UseReceiptDataList=1&ReturnSigType=PNG&CreateFile=false&TopazType=1';
docDescription = docDescription.replaceAll(' ', '%20');
reqUrl += '&ReceiptData=' + docDescription;
fetch(reqUrl)
    .then(data => { return data.json(); })
    .then(data => {
        console.log('data', data);
    })
    .catch(e => {
        console.log('Error fetching image', e)
    })

What it does is communicates with a device Verifone Signature pad, after signing in and click submit in the device it shows me this Json: which is the image of the signature….How can i display this signature in my Html form? Please help.

{"request":"SIGCAPTUREWAIT","successful":true,"response":{"FileName":"","PNG":"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"}}

I use Canvas but I am not sure how to add this piece of code into my canvas to display signature.

var docDescription = 'Please sign wire transfer request';
var reqUrl = 'http://localhost:12001/SigCaptureWait?ResponseType=API&UseReceiptDataList=1&ReturnSigType=PNG&CreateFile=false&TopazType=1';
docDescription = docDescription.replaceAll(' ', '%20');
reqUrl += '&ReceiptData=' + docDescription;
fetch(reqUrl)
    .then(data => { return data.json(); })
    .then(data => {
        console.log('data', data);
    })
    .catch(e => {
        console.log('Error fetching image', e)
    })

Google Books API returning 404 on Bookshelf GET

I run a website for my book club that uses Google Books to pull cover images. To do this, I add the books to the Have Read bookshelf on my Google Books library and then I use this GET in JavaScript.

`
url = ['https://www.googleapis.com/books/v1/users/myID/bookshelves/4/volumes?key=' + APIKey + '&maxResults=40']; 
xmlgoogle.open("GET", url[0]);`

This has worked completely fine for years, but in the last week, I’m getting a 404 when I try to retrieve the bookshelf data. Has something changed about the Google Books API that makes this GET no longer work?

Normally, I get a list of book data. Now I get a 404 from the exact same command with the exact same library.

Playwright JavaScript: How to wait for a network request with a particular request payload?

It is easy to wait for a request if they have unique endpoints.
But how do we wait for a particular request if all the endpoints are same, but the request payload varies, eg GraqhQL middle layer.
In this case all the backend calls are done using https://myapplication.com/graphql-v2, but the request payload differs.
I want to intercept this request where payload contains the string getUserDetails

something on similar lines, but better :

const response = await page.waitForResponse(
      (request) => request.url().includes('/graphql-v2') && request.body().includes('getUserDetails')
)

enter image description here

Vercel cannot find multer package

I wrote backend code that uses the multer package tried deploying it on vercel. But I got this error screen and the following error message in the logs:

enter image description here

Error [ERR_MODULE_NOT_FOUND]: Cannot find package ‘multer’ imported from /var/task/backend/controllers/entriesController.js
at new NodeError (node:internal/errors:405:5)
at packageResolve (node:internal/modules/esm/resolve:965:9)
at moduleResolve (node:internal/modules/esm/resolve:1022:20)
at moduleResolveWithNodePath (node:internal/modules/esm/resolve:876:12)
at defaultResolve (node:internal/modules/esm/resolve:1242:79)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:403:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:372:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:249:38)
at ModuleWrap. (node:internal/modules/esm/module_job:76:39)
at link (node:internal/modules/esm/module_job:75:36) {
code: ‘ERR_MODULE_NOT_FOUND’
}
INIT_REPORT Init Duration: 308.35 ms Phase: init Status: error Error Type: Runtime.ExitError
Error [ERR_MODULE_NOT_FOUND]: Cannot find package ‘multer’ imported from /var/task/backend/controllers/entriesController.js
at new NodeError (node:internal/errors:405:5)
at packageResolve (node:internal/modules/esm/resolve:965:9)
at moduleResolve (node:internal/modules/esm/resolve:1022:20)
at moduleResolveWithNodePath (node:internal/modules/esm/resolve:876:12)
at defaultResolve (node:internal/modules/esm/resolve:1242:79)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:403:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:372:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:249:38)
at ModuleWrap. (node:internal/modules/esm/module_job:76:39)
at link (node:internal/modules/esm/module_job:75:36) {
code: ‘ERR_MODULE_NOT_FOUND’
}
INIT_REPORT Init Duration: 417.87 ms Phase: invoke Status: error Error Type: Runtime.ExitError
Error: Runtime exited with error: exit status 1

Here’s a portion of my package.json:

"dependencies": {
    "body-parser": "^1.20.2",
    "cors": "^2.8.5",
    "dotenv": "^16.3.1",
    "express": "^4.18.2",
    "firebase": "^9.23.0",
    "firebase-admin": "^12.0.0",
    "luxon": "^3.4.4",
    "multer": "^1.4.5-lts.1",
    "uuid": "^9.0.1"
}

Multiple Subjects exist while importing CoreModule into another component module

So in my app.component contains the header on every page (CoreModule imported in app.module) as well as an app-routing.module that loads modules based on routes (SomeContainerRoutingModule in this case)

The problem is when I try to import the DropdownComponent which is part of the CoreModule into the container, it treats the Subject as a separate object and doesn’t include the Observables as the ones found in the header. When I exclude the CoreModule from the imports the Subject works fine, but the DropdownComponent is no longer on the page.

How can I use the same Subject/service while also adding the core component to the page? Shouldn’t CoreModule already be imported from the root app.component that the header resides on?

CoreModule

...
declarations: [HeaderComponent, DropdownComponent],
providers: [MessageService]
export class CoreModule {}

SomeContainerRoutingModule

...
imports:[...
//CoreModule
//removing this makes Subject work. Adding it makes the component appear
...

MessageService

export class MessageService {
private subject = new Subject<any>();
sendMessage(message){this.subject.next(message);}
getMessage(){return this.subject.asObservable();}
}

I’ve tried adding the core component to the imports of the container module but I get Error: Type DropdownComponent is part of the declarations of 2 modules: CoreModule and SomeContainerRoutingModule!….
I’ve also tried adding the service to the container module but it doesn’t seem to affect anything.