Questions tagged [require]
In interpreted languages like Lua, PHP and Ruby, "require" is a statement that tells the interpreter to include a certain source-file at that position where the "require" statement has been placed.
3,177
questions
0
votes
0
answers
8
views
Import nor require are working inside my jest test files in my node.js app
I just installed jest into my node.js app. I can run npm test just fine, until I attempt to import something from another file.
I have a file called channel.test.js and I've tried the following:
...
0
votes
0
answers
25
views
TypeScript avoid TS2749 and avoid using typeof on classes imported using require (run using bun)
The code
Given a file named foo.ts containing a class:
export default class Foo { name = 'bar' }
Given a program using this module:
const Foo = require('./foo').default
function logFoo(foo: Foo) { ...
0
votes
1
answer
27
views
How to import files inside functions when using Vite (Vue 3, Nuxt 3)
I have a question.
Regarding migration from Vue 2 => Vue 3 and Nuxt 2 => Nuxt 3, and the new use of Vite,
the function require() is no more supported.
I have to migrate this function which is ...
0
votes
0
answers
26
views
JavaScript import statements changing to require after compilation
I have some JavaScript helper modules I use to access frequently used functions. It usually works fine but lately something weird is happening and I can seem to find a solution. So when I want to ...
0
votes
1
answer
26
views
require an image in React [duplicate]
in my React code this return true:
console.log(`${person.image}` === "../images/profile/mehraboon.jpg");
and this works:
return (
<section>{<img src={require("../images/...
2
votes
2
answers
34
views
Node REPL : Latest Script file contents are not getting fetched using require method
While using node js repl to run run require command latest file changes are not getting captured.
OS => Windows 11
Node Version => 16.6.0
Let script.js has content
global.testObject = {};
...
-1
votes
0
answers
49
views
Require in ESM not supported
I have a problem. I integrated the storybook in our project with Next JS, Docker, yarn v1.22.19. I know about it, it is a very old story book, but I don't think that's the problem. After that I used ...
0
votes
0
answers
22
views
getting error 'Invalid field namespace' when using required_without tag in ValidateMap (go-playground validator)
I have a map that looks like this:
m := map[string]interface{}{
"config_v1" : "...",
"config_v2" : "...",
}
and I want to add the rules :
config_v1 must ...
0
votes
1
answer
28
views
How do you use the contents of a Racket submodule, which uses definitions from the defining module, in the defining module?
I need to require a module that horribly pollutes the namespace, and I'd rather not use prefix-in because it makes the code that uses it really ghastly, so I decided to try to move the code that uses ...
0
votes
0
answers
20
views
cannot require package 'obj2gltf' with webpack
original Question: facing 36 errors after require("obj2gltf") with webpack
I try to load the module 'obj2gltf' with webpack. The configuration works when i delete the row const obj2gltf = ...
1
vote
1
answer
36
views
Is it possible to load modes in interactive functions before the interactive prompt is executed?
This is a follow-up question to this original question.
I try to provide a custom interactive function, requiring the loading of another package, right after startup of Spacemacs. My problem is that ...
2
votes
1
answer
44
views
Is there a difference between global require and local require within a function
AFAIK, once the module has been loaded, lua caches the result into package.loaded[modName]. Does this statement hold true irrespective of where we are doing require "module"?
Following ...
0
votes
1
answer
19
views
I want to use crypto.hash inside the chainlink functions
I want to use the crypto package to use the crypto.getRandomNumbers and crypto.createHash() inside the source.js in the 1-simple-computation of the chainlink functions.
This is my code :
// calculate ...
0
votes
0
answers
6
views
I have a error RemotingSendRequestException
I have a error when I use Springboot3+graalvm+rocketMq,if I use jar,I can do it ,but when i get Graalvm ,itis error.could you help me
enter image description here
enter image description here
I want ...
0
votes
1
answer
40
views
How to use require in Discordia(luvit)
So when i just use require(filename) it doesn't work, i mean if i use require("filename"), it thinks it's a module so can't open it, it only works if i use require("./filename.lua")...
0
votes
1
answer
22
views
Import module file with folder
so i'm trying to make a npm module, and in a moment, i've see a module required like this (example): const module = require("module.js/folder")
When i try manually in my test folder, no ...
0
votes
0
answers
47
views
Can't walk dependency graph - browserify
Using Browserify to bypass the 'require' issue.
Have these lines in my code:
let CryptoJS = require('node:crypto')
const util = require('util');
var soap = require('strong-soap').soap;
When I try to ...
1
vote
1
answer
40
views
Is there any way to find out every isolated PHP file in a project?
I'm working on legacy PHP based E-cormmerce project, and there are so many files that are not being used.
I just want to remove every PHP file that are not included or required by another file.
...
0
votes
0
answers
56
views
webpack build successful but when start it return webpack config on terminal and close with ValidationError: Invalid configuration object
using webpack to build and run the vanilla javascript project which have node js and express js, webpack build working fine but running after making some changes in webpack.config.js file, it ...
-2
votes
1
answer
42
views
Why import can be used in this commonjs module?
Code is here: https://github.com/timewalker08/wechaty-test/tree/master
According to nodejs document:
If the nearest parent package.json lacks a "type" field, or contains "type": &...
0
votes
0
answers
24
views
Types of function's parameters are not considered when imported from a commonjs module in TS
I'm a beginner to TS, in this example I have a module model.ts, where I export a function with a param
// model.ts
function go(name: string) {
console.log(typeof name);
return name;
}
export { ...
0
votes
1
answer
130
views
Dynamics 365: Init of Application Insights logging for Javascript in external files
I want to put my connectionstring and the init of the AppInsights-Logger in separate files and use (import) the logger in my main javascript file.
What I have done so far causes the main file not to ...
0
votes
0
answers
52
views
Electron React TypeScript window.require("fs") returns 'any'
I'm using this to enable node access in my component.
const mainWindow = new BrowserWindow({
height: 600,
width: 800,
webPreferences: {
preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
...
0
votes
0
answers
20
views
How to use path.js as an external resource without require (jsfiddle)
I wanted to test out path.js in jsfiddle, so I decided to make a 2-3 line jsfiddle script. I included path.min.js as an external resource, but when I try running it, I see errors that the join ...
0
votes
1
answer
61
views
Azure Web App: Can't find variable: require
I'm running Flask app on Azure. I have a arcgis js globe that I have in the browser. It starts like:
<script src="https://js.arcgis.com/4.22/"></script>
<script>
...
1
vote
0
answers
25
views
Is there an esLint rule to avoid separated require() groups?
I would like to avoid having multiples require groups but have them all on the same one.
There is a way to do so (in imports) with tsLint using ordered-imports and setting the property grouped-imports ...
0
votes
0
answers
16
views
How to use node.js require() method in web browser?
So I want to build a website that queries data from a MySQL database. I installed the mysql package in Node.js (command: npm install mysql).
On my local machine it works but it doesn't in the browser ...
0
votes
1
answer
42
views
Dynamic synchronous require targeting itself or current working directory
I'm writing a NodeJS package and part of the function does a dynamic synchronous require in the following manner:
import { createRequire } from 'module';
const require = createRequire(import.meta.url);...
0
votes
1
answer
49
views
Values are not updating from Index.php to example.php
Values are not passing when the files are included. Even i tried global $subidone; and $subidone = $_GET['subidone']; but not working
Index.php Code :
if (isset($_GET['adgroup_id']) && $_GET['...
0
votes
0
answers
590
views
Update Angular to version 16 and its dependencies specially using require keyword
I tried to update my Angular project from version 15 to 16 without success.
After I update my packages with 'npm-check-updates' command. I get 48 moderate severity vulnerabilities. and when I call ...
0
votes
0
answers
29
views
PHP Warning: require(../DB_Info.php): Failed to open stream: No such file or directory [duplicate]
the last time i ask a question here i ended up solving it myself.. But not his
time, been searching hours again till i can't think anymore.. Maybe i can pick your brain.
Here is my problem.
I have an ...
0
votes
0
answers
21
views
CLI errors during Headless CMS Sanity integration with Nextjs
First, I have created a new template using npx create-next-app@latest. After that I have used the command suggested by sanity website to integrate sanity studio in my nextjs project.
That command is ...
0
votes
0
answers
26
views
how to avoid circular dependency in requiring files
I am making a inventory management system. I have two models sales and orders. Sales contain bill data and each product purchased is in orders model. I want to use pre update hook to update orders and ...
0
votes
0
answers
26
views
How can I tell in what 'required' file a define() constant was defined, in php?
I'm working on a larger project with a lot of autoloaded files.
There are several files which purely define a bunch of global constants like this:
define("CONSTANT_ONE", "constant one ...
1
vote
1
answer
22
views
How to add a var as source parameter of ImageBackground
What i want to do
I built an React-Native App. On the HomeScreen there is a FlatList containing 1 item. The item in the list is a Pressable, so i can click on the area and get navigated to the ...
3
votes
0
answers
765
views
Electron/React; Uncaught Error: Dynamic require of "child_process" is not supported
I am a novice so please don't criticize me. I have been searching for a solution for 10 hours but couldn't find one. I am trying to create a 'container' application that either downloads other apps if ...
0
votes
1
answer
101
views
Getting error while Sending SMS on phone number using MessageBird
The problem is while sending the test SMS I receive an error in the first line of the code and the error is require(...) is not a function:
The code is given below:
const messagebird = require('...
0
votes
0
answers
71
views
TypeError: Encoders require their input to be uniformly strings or numbers. Got ['float', 'str']
I am working on classification problem where my dataset has categorical and numerical columns.
I tried to make Label encoding for categorical features
# Label encoding for categorical features
encoder ...
2
votes
1
answer
63
views
import equivalent for require in app.use()
I have the following code in my server.js file:
import express from "express";
import fs from "fs";
const app = express();
fs.readdirSync("./routes").map((r) =>
app....
-2
votes
1
answer
19
views
need your assistance to run the redux app
Please help me to solve the error what I am facing when it's running the code ..
Unable to solve this problem.. tried out my best..
I've also added import to import the required elements. I'm just ...
0
votes
0
answers
69
views
Node.js: How to avoid 'Cannot use import statement outside a module' error when using Sequelize and Telegraf?
Use import and require at same time
const Sequelize = require('sequelize')
import {Telegraf} from 'telegraf'
const bot = new Telegraf("Token")
const sequelize = new Sequelize("bot&...
0
votes
2
answers
911
views
require_once(): Failed opening required > '/wp-load.php'
I have a file, mail.php - it's in the public_html/scripts/ directory.
I have an ajax javascript function that calls it:
<script>
function sendEmail() {
var variable1 = 'hello'; // Get the ...
1
vote
0
answers
72
views
TypeError: ... is not a constructor when requiring class from Mocha test
In a trivial project, I have the following files:
app/taxCalculator.js
test/taxCalculator.js
In app/taxCalculator.js there's a class definition that starts thus:
class TaxCalculation {
constructor(...
0
votes
1
answer
61
views
User require and Import within same file react js chrome extension
I'm developing a google chrome extension with reactjs and I need to use translate module or package within my chrome extension but I'm failing to use it and I'm facing error to switch require command ...
2
votes
1
answer
144
views
I want to know how to include an outside script in inDesign idjs file. When it was extend script I used //@include
I want to be able to import or require inside of inDesign idjs script.
I have tride require, import, and //@include
0
votes
0
answers
38
views
PHP - failed to open stream: No such file or directory but file exists [duplicate]
This is the error I'm getting when I try to require a PHP function file on my main page:
require("./funkcije/vratiZadatke.php");
I think this line itself works because I don't get an error ...
1
vote
1
answer
372
views
require a file on condition with next.js
In my next.js + express.js (custom server within next) app, there is a flow of follows:
user selects a parameter with drop down menu.
upon her/his selection of parameter, a process is executed in ...
0
votes
1
answer
82
views
Rename multiple files using Node JS
I just started learning Node JS and I don't know how to solve this:
I have a folder with 291 files, and I want to rename all those 291 items in order, with a title that I've saved in an Array. This is ...
0
votes
0
answers
1k
views
Caught ReferenceError: require is not defined in app.js
I have a app.js file that requires express as a constant:
const express = require('express');
Im getting the error:
p.js:1 Uncaught ReferenceError: require is not defined at app.js:1:17
after running ...
1
vote
0
answers
58
views
Why is my require statement an immediately invoked function and why does it give errors?
For uni I'm working on node.js servers. I'm following the code used in the lectures and I got in trouble with persistent sessions in express.js. In the lecture slides the following require is used:
...