All Questions
128
questions
0
votes
0
answers
32
views
Create one nodemailer test account and hold it in a module global
I have a nodejs application. One of the modules is for the mail transporter. I'd like to create a mail test configuration one per launch and store it (in global) so it can be reused.
However, during ...
0
votes
0
answers
74
views
Unexpected global objects in node 18 [duplicate]
When executing with node v18.17.1, why are there different versions of the global object?
function foobar() { return this; }
console.log(this); // {}
console.log(foobar()); // Large output, as below:
...
0
votes
0
answers
44
views
get all globally declared variables and functions in globalThis in node.js [duplicate]
Is there a way to get all the variables, const, function declarations in the global or globalThis object of a nodejs file.
the print of my console.log(process).
> console.log(process)
process {
...
-1
votes
1
answer
41
views
How can I delete an object and capture the deletion of the object event?
There are two things I am trying to do:
delete an object whether a const or let - right way to do it in node.js
capture the delete or assignation of null or undefined to cInst or dInst object in the ...
2
votes
1
answer
147
views
`this` keyword is undefined in NodeJS [duplicate]
I am having trouble understanding "this" keyword behaviors in JavaScript (NodeJS - v16.19.1). According to this site, "this" keyword in the global execution context will reference ...
1
vote
0
answers
54
views
Node.js: global error handler not working
I am trying to create a global route to handle the error pages like 404, 500, etc.
src/index.js
const App = express();
import Accounts from './application/accounts/routes.js';
import AccountTypes ...
1
vote
0
answers
103
views
How to access TypeScript typings for Electron’s extended global process object?
Assume we have a library of functions like the following, intended to run in the Electron main process and access the global NodeJS process module:
function isMainProcess() : boolean {
return ...
0
votes
0
answers
58
views
Prevent Typescript compilation when declared globals aren't in scope
Considering the following Node.js code that adds a function to the global object
// sum.ts
declare global {
function sum(a: number, b: number): number
}
function sum(a: number, b: number) {
...
0
votes
2
answers
1k
views
I can't understand how do 'global`s work in TypeScript/NodeJS and what is their difference?
I am reading a code like below:
import { MongoMemoryServer } from "mongodb-memory-server";
import mongoose from "mongoose";
import request from "supertest";
import { app }...
1
vote
2
answers
2k
views
structuredClone not available on global object in nodejs app
structuredClone doesn't work in my NodeJS app. When I try to use it I get the error: structuredClone is not defined nodejs.
If I create a simple file, and run:
console.log({
globals: Object.keys(...
0
votes
0
answers
74
views
global variable is giving back undefined [duplicate]
in node js i have this code
const scraper = () => axios.get("https://thehackernews.com/").then((urlData) => {
const $ = cheerio.load(urlData.data)
videoTitle = $(".home-title&...
1
vote
1
answer
741
views
Nodejs Set a global function and call a nested function
My Main function
import AppLauncher from './Applauncher'
function Mainfunc() {
global.app= AppLauncher()
global.app.start('index')
}
AppLauncher.js
function AppLauncher() {
function ...
8
votes
3
answers
13k
views
Error: Cannot find module '../../package.json'
So, I've seen other similar issues. There are a lot, but I can't seem to find a solution for this.
I've already deleted node_modules folder and package-lock.json file from /{username} , where my ...
0
votes
1
answer
795
views
Globally installed NPM packages not recognised
I had a system crash. While trying to fix it, I deleted a few files and (I may be wrong here), I deleted ~/.profile file among them.
After system restore, my globally installed npm packages are not ...
5
votes
3
answers
2k
views
Augmenting global scope in Typescript not working
to get some context I'm working in a microservices app where I have two similar services with practically the same packages. In order to make some testing I add a function to the global scope and ...