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,132
questions
0
votes
1
answer
21
views
Uncaught ReferenceError: require is not defined in nodeJs
I know that there are many questions already with this error message, but I have tried all the solutions suggested but it doesn't work for me.
I want to use websockets to create a server to build an ...
0
votes
1
answer
22
views
Templated requires clause fails
I have a set of classes roughly defined as follows:
template <typename U>
class Iterable {
// More code
};
class Container : public Iterable<Element> {
// More code
};
class ...
1
vote
2
answers
42
views
require is not defined in a new js file
I want to use anime.js.
For install this library i need to do this:
$ npm install animejs --save
const anime = require('animejs');
I want to writte the code in a js file named "anime.js"
...
0
votes
0
answers
26
views
IUP is not working for Lua and throws an error that the module is not found, even if the file IUP is calling is in the same file
I have installed the IUP GUI for Lua (https://www.tecgraf.puc-rio.br/iup/, the website is in English, although it doesn't look like it). I have tried running IUP on my computer using their tutorial ...
-1
votes
0
answers
15
views
Wordpress admin blank on mobile
i have a problem with admin panel from mobile phone, in particular with iPhone. I'm able to do login and then nothing, blank page. From desktop everything works good. I found the "problem" ...
0
votes
0
answers
23
views
How to load require so I can use jspdf?
I would like to use the web package jspdf in javascript.
To do so, I installed jspdf package. And here is my function to generate a pdf :
function genererRecapitulatifPdf() {
const { jsPDF ...
0
votes
0
answers
13
views
Loading 'A' lua module from 'B' lua module using package.cpath package.path
Applying this example of module in HighResolutionTimer, enter link description here, I just encounter some issue attempting to call by B module the A minimalist module that use a HighResTimer.dll ...
-1
votes
0
answers
34
views
When running rails run: bin/rails:3:in `require_relative': cannot load such file -- C:../config/boot (LoadError) from bin/rails:3:in `<main>'
I want to create an application occupying rails and since I also want to run it, when doing so I get this `require_relative' error: cannot load such file. I've searched for options but still can't ...
0
votes
0
answers
22
views
Function not returning to another file [duplicate]
so I have a problem.
I have two files, testMode.js and initialize.js, testMode.js requires initialize.js and runs the initialize functions, all works well until there's time to return back to testMode....
-2
votes
0
answers
16
views
Why require() functions read images as modules inside react app?
we are trying to understand why require, that is a Node built-in function, works to import modules inside files: why if we use require for images, this function works fine too.
Why and how images are ...
0
votes
0
answers
23
views
Error: Route.get() requires a callback function but got a [object Undefined] - search express
I'm trying to fix a search functionality with query (express nodeJS) but I get this error message... Any ideas what I'm missing?
Thanks!
the route:
const SearchController = require("../...
0
votes
0
answers
13
views
How to find and kill all the process concatenated to a module require event in node.js
I have an app that requires a "requester" module after a function call. After the use of that module, I need to delete it, because after importing it starts sending requests to a saas ...
0
votes
1
answer
53
views
Included function not found in PHP file
I have read a bunch of questions and answers (like this and this and even this which might be more relevant) on SO regarding this. They all deal with a file not being found due to a path incorrectly ...
0
votes
0
answers
29
views
Cannot get any js library to load in my js code, but does work on test page
I have js websocket app with a js.index file and a html file. I am using node.js in VS Code to code. I cannot get any js library file to work in my js.index code. I CAN get js libraries to work on a ...
1
vote
1
answer
46
views
Node.js: How to import/require a file, run its commands and access its updated variables like in Python?
In python you can just have file1.py with a class called "class1" like this:
class class1:
def __init_(self, var1, var2):
self.var3 = var1
self.var4 = var2
...
1
vote
1
answer
55
views
Could not resolve symbol: clojure.core.logic/membero
I am trying to run the function membero as outlined by
https://clojuredocs.org/clojure.core.logic/membero
(ns clojure-noob.core
(:gen-class)
(:require [clojure.core.logic :as logic]))
(defn -...
0
votes
1
answer
34
views
PHP Trait versus Require or Include
I'd like to understand why discussions of Traits never seem to include comparison with Require, but always compare with inheritance.
It's my understanding that Require is essentially the same as a ...
0
votes
1
answer
62
views
ReferenceError: Can't find variable: require expo
I am getting this error in my expo project
ReferenceError: Can't find variable: require
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:4 in reportException
at node_modules/...
0
votes
0
answers
14
views
Node js - Global variables to be used in different files
I have a main file called index.js. Here, I want to do some global stuff which can be used by different js file:
const algoliasearch = require('algoliasearch');
const firebase = require('firebase');
...
0
votes
0
answers
53
views
How do I replace ```require()``` in this code?
I am following a tutorial on Discord.js. I have had to change require to import for node:fs and node:path.
On line 34, however: (const command = require(filePath);) there is another require ...
0
votes
0
answers
18
views
What is the correct way to use modules in Node.js? [duplicate]
Almost every tutorial I look at for Javascript uses require for accessing code from other files. When I run the code, however, I get this error:
ReferenceError: require is not defined in ES module ...
0
votes
0
answers
27
views
Load a module in requirejs and inject it with a specific dependency
I need moduleA and moduleB to have a different context.
moduleA and moduleB are exisisting javascript libraries which both request a 'context' module.
Is it possible when we require moduleA or moduleB ...
0
votes
0
answers
24
views
How to require a JS file from an external source/directory without path issues?
How do I require another module from a different directory without having path issues?
For example,
src/index.js, has a require('../other/main') statement
Oh, there's an error, because in the main.js ...
0
votes
0
answers
23
views
How to convert a dynamic require to a dynamic import
I have the following React component, called Profile, which imports and displays a specified profile image. The link to the profile image is provided in it's props.
const Profile = ({name}) => (
&...
0
votes
1
answer
41
views
Loop and If statement to check and load packages
Why wont require take a vector of packages? Also is there a way to split pkg for both install.package and BiocManager? Thus, if packages fails to install with install.package, check with BiocManager?
...
1
vote
1
answer
22
views
Why we don't directly do "app = require('express')"?
Almost in all NodeJS application codes I see the following lines:
express = require('express');
app = express();
And the question comes to my mind: why we don't directly do:
app = require('express');...
0
votes
1
answer
16
views
Node.js & mongoDB: uncaughtException: Cannot overwrite `User` model once compiled
I have this import
const User = require("./Usermodel")'
and I want to change it to
const User = require("./UserModel")
When I try to change the import-spelling, to be consistant ...
0
votes
1
answer
32
views
Error Quarto require invalid module (bertin.js)
I have developed the library bertinjs which allows to make svg interative maps. In Observable, require("bertin") works. In Quarto, require("bertin") does not work. The following ...
1
vote
1
answer
42
views
require file from another path in Lua
The problem is that i cant find the lua file to use.
the filesystem looks like this:
`|-- plugin
'|-- functions
' -- helpers.lua
|-- tests
'|-- integration
'|-- unit
' --...
0
votes
1
answer
33
views
Node/Twilio multiple config variables in require function
I was wondering if any other people have managed to find a way to use multiple account sids and auth tokens when using Twilio for Node. The documentation is pretty straight forward, and I am able to ...
2
votes
1
answer
51
views
requiring a directory rather than a js file
I come across a piece code like this in an index.js file:
exports = module.exports = require("./src")
Not sure what the exports = module.exports bit means.
And not sure what it means to ...
0
votes
1
answer
47
views
Convert Require to Import
I am currently working on a Discord.js Bot in replit. The example code I found, which I used to get started with the bot, begins with this line of code.const { Client, Intents, Message } = require('...
-2
votes
1
answer
49
views
require('./file') is undefined in one file, but not others
I have an npm project I am working on and am having a strange issue with require. I have paths in one file and am using them like, const paths = require('./paths'); but I have one file where paths ...
0
votes
1
answer
25
views
How to use peerjs (import and require both fail)
I want to use peerjs in a script (that I use in a html file).
When I try import Peer from "peerjs", I get an error saying "Cannot use import statement outside a module".
When I try ...
0
votes
0
answers
38
views
Chalk issues in NodeJS
[Yes, I know that there is another post just like this, link]
For some reason, when I use Replit for programming in Node, I can not use import.
I am using replit (online IDE). In the link mentioned, ...
-3
votes
1
answer
60
views
C++ requires keyword does not work, compiler error [duplicate]
Code is supposed to work but it gives compiler error:
#include <iostream>
#include <concepts>
using namespace std;
template <typename T> requires integral<T>
T add( T a, T b){
...
0
votes
1
answer
32
views
How to copy a file in node.js?
I'm learning Node.js and using the Hyper Terminal and Visual Studio Code.
I want to copy a file through Hyper Terminal and notice that const fs = require("fs"); doesn't work in CommonJS.
So ...
0
votes
0
answers
31
views
How to access variable from a function in a required file that required another file? Can I do it directly, without using $GLOBALS? [duplicate]
So I have the following 3 files:
index.php
<?php
require("require/functions.php");
$g = getGroup();
var_dump($data);
die();
?>
functions.php
<?php
function ...
0
votes
3
answers
38
views
Require a class from another class - php
I'm learning PHP. And I have a problem that I can't understand. This my situation:
I have a directory called Lib. This is the structure of my directory:
In the directory database I wrote a class ...
1
vote
1
answer
150
views
AWS Lambda Function: Cannot find package imported
I added the knex module (for example) to my function lambda (Node.js 14.x) from a lambda layer.
When I deploy my function in AWS Lambda and I use require in my lambda function works but with import ...
0
votes
0
answers
47
views
Prevent PHP leaking variables with include or require
I have unwanted arguments leaking into my template.php.
function template($template, $args) {
$foo = $args['bar'];
extract($args);
include __DIR__ . '/' . $template . '.php';
}
In the ...
1
vote
0
answers
70
views
"ReferenceError: require is not defined" when importing a js file
This is an old question that has been asked many times. I have tried all the solutions but nothing works.
I am using MongDB and want the names of users stored in the database to be displayed on the ...
0
votes
1
answer
506
views
Error: module not found in React, cannot resolve 'url' in ...axios/lib/adapters
I'm getting this error and am not sure firstly why it appears and secondly how to resolve.
the error message:
Compiled with problems:X
ERROR in ./node_modules/axios/lib/adapters/xhr.js 17:10-24
...
0
votes
1
answer
28
views
Optional runtime dependency for Ruby gem with executables
I'm writing a gem aipp which exposes a few executables, nothing fancy here:
#!/usr/bin/env ruby
require 'aipp'
AIPP::NOTAM::Executable.new(File.basename($0)).run
Parts of the gem optionally use ...
1
vote
0
answers
114
views
Browserify eslint require(...).pathToFileURL is not a function
I am trying to bundle the code below using browserify
const { ESLint } = require('eslint');
console.log(ESLint);
And when I include the generated bundle in a html file, I get this error.
Uncaught ...
0
votes
0
answers
79
views
Typescript: import { groupBy } from 'lodash' ReferenceError: require is not defined
I'm trying to use groupBy from lodash in a .ts file like this:
import { groupBy } from 'lodash';
But after tsc .\index.ts -w the resulting index.js turns that import into var lodash_1 = require("...
0
votes
1
answer
8
views
i am using a small php microframework and keep getting an error Uncaught Error: Undefined constant "mu"
Fatal error: Uncaught Error: Undefined constant "mu" in E:\xampp\htdocs[[myphpframework]]\mu-clean\examples\hello1.php:3 Stack trace: #0 {main} thrown in E:\xampp\htdocs[[myphpframework]]\mu-...
0
votes
0
answers
40
views
Convert dot to png in NodeJS
I'm new in nodejs and now I'm using the version 14.19.1 and I want to convert a dot file into png, I've tried with a library whose syntax for importing is like that:
import {renderDot} from 'render-...
1
vote
1
answer
72
views
How to use require() in html
I try to use require() in html. I try to use require in JS but I get the following error Uncaught ReferenceError: require is not defined
I wonder how can I use require function on client browser. And ...
0
votes
0
answers
40
views
what version of Lua does raylib use
When I try to use raylib with lua + zerobrane it says it can't require it , here is the output from zerobrane. would not let me copy output but I think you get the idea.
Here is my code which is just ...