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.

0
votes
1answer
22 views

Is there a way to import from this node module with 'import' instead of 'require'?

I'm using this node module 'deep-equal' () and so far the only way I've been able to access the function in it is with var equal = require('deep-equal');, as suggested in the documentation. I usually ...
0
votes
1answer
14 views

Why I can't resolve image with React Native

I'm trying to resolve image with the path name, but whatever I tried there's nothing workss well. Here is the path way: images | | | | | myImage.png | components | UI | |_ _ ...
1
vote
0answers
22 views

Error working with Lua modules using LuaBridge and C++

I am unable to include a Lua file in another Lua file. I am compiling Lua using C++ and LuaBridge. Here is my main function. Very very small. lua_State* luaState = luaL_newstate(); ...
1
vote
1answer
38 views

Intercept all Node's require calls

I'm trying to figure out how to intercept all Node's require calls, so that I can log them. There are a few questions about this already but the suggested methods there fail at intercepting all ...
0
votes
0answers
19 views

'Uncaught ReferenceError: require is not defined at […]' on Electron 5.0.1

I am currently working on my first application using Electron (v. 5.0.1) and, opening Chromium's DevTools, it comes out that "require" is not defined. Looking on the Web, I found that in 5.0+ ...
0
votes
1answer
37 views

Why do these 2 NodeJS / Typescript imports give different results?

In a NodeJS project, I have installed typescript 3.2, express 4.16 and @types/express 4.16 I am writing my application in Typescript to be later transpiled. The documentation for @types/express say ...
7
votes
4answers
135 views

What could be the reason that `require` doesn't work in some places?

Loading a module (ABC) with require works in one module of a distribution while it fails in another module of the distribution. What could be the reason that loading ABC with require fails in one ...
0
votes
1answer
20 views

Watchify - Uncaught ReferenceError: require is not defined

i need Node.js feature like require() function in my javascript code so i am using watchify, but it is still giving me error Uncaught ReferenceError: require is not defined at jsfile.js:3 despite the ...
1
vote
0answers
33 views

php error_log(“”) below require

I am trying to print to a log. It will work at the very top of the page but not below a require statement. This works... <?php $log_file = "../../../../errors.log"; $error_message = "test! \n";...
0
votes
0answers
14 views

Why does this require scheme not working as expected?

I have a web-project for browser written with help of browserify to get power of npm packages. In one file i am creating array with data that i need to use in another module. //a.js var arr = require(...
0
votes
1answer
16 views

How to use CommonJS exports and imports with SocketIO?

Im trying to modularize my server-side code a little bit with CommonJS Modules. So far this is my module with a function in a motorDriver.jsfile: var rpio = require('rpio'); function motorDriver() { ...
2
votes
1answer
29 views

How to use svg.js on Observable notebook

I started learning to use Observable a few days ago. I can use svg.js version 2.7.1 by using SVG = require("svg.js") // 2.7.1 But when I try to use version 3.0.12, this doesn't work. SVG = require(...
0
votes
1answer
39 views

php/html: Require doesn't work in basic html / php code

So im trying to import a header.php into my index.php file file but it just doesnt work. header.php: <!DOCTYPE html> <html> <head></head> <body> <header> ...
0
votes
2answers
26 views

Require doesn't work in basic html / php code

So im trying to import a header.php into my index.php file file but it just doesnt work. index.php: <?php require "header.php"; ?> <main> <p> online! </p> ...
0
votes
1answer
23 views

How to separate methods into different files and than bundle them in one file to require this

let's imagine you wanna build a file that contains different methods. For example: file bundler.js that need method a(), b(), c(). But these methods are very complex and take much lines of code, so it ...
0
votes
0answers
31 views

How to parallel require js file?

I do want to load lots of js files in order to get the global variable in it. But the variable is very complex and leads to waste some times. So I'm trying to require the js file in parallel by using ...
0
votes
0answers
17 views

“Module not found” for absolute import within private package

tl;dr: How can I import/require via absolute path within a nodejs package compiled from Typescript? Long version: This question is probably a dup, but I've been searching for a very long time now: ...
0
votes
0answers
20 views

Error: Cannot find module '../img/airlines/Caspian.png' in react

in my react project i have a const and after this i use map for returning image const images=[ {airline: "Aseman",src:'../img/airlines/Aseman.png'}, {airline: "Ata",src:'../img/airlines/Ata.png'}, ...
-1
votes
0answers
17 views

Downside for using require() to include module/exteranl script without assigning it to variable - Javascript?

I wondering if instead doing this const hello = require('something') hello() Can we shorten it to require('something')() This probably is not recommended way to code due to readbility, but I ...
3
votes
2answers
109 views

Codemod for Babel `import` into commonjs `require`

I'm looking for a way to converting a full node-project's Babelimports into CommonJS-style require(). The goal is to get rid of Babel. Considering node.js has things like async/await built-in ...
0
votes
0answers
27 views

How to scrape the content of a webpage in an ionic App

I am currently building an ionic app, one of its functionalities consists in scraping some elements of a webpage and push these elements on firebase (to be displayed later on in another context). And ...
1
vote
0answers
62 views

require(): “Is not a function”

I'm trying simplify going through code by creating a function which works as a class for the window. When doing so, it smacks the following in my face: windows.Main.initialize is not a function If ...
0
votes
0answers
36 views

including client side functions like “require” on web applications [duplicate]

So I am learning how to scrape data from websites for a school project. So far I have successfully scraped data using the command prompt but I want to use that data for visuals on a website using a ...
2
votes
0answers
37 views

PHP document root and require

I am about to use an old software I wrote when I had very little knowledge about PHP and now I have a lot of: require("/path/file.php"); that do not work anymore because $_SERVER['DOCUMENT_ROOT'] ...
0
votes
0answers
23 views

I have defined a the Path to included files but including them using the Defined Paths does not work

I am currently building a beginner project in PHP. I am trying to define the File Paths inside initialize.php. when I access the page, I get this error require_once(): Failed opening required './...
2
votes
0answers
39 views

Webpack cant resolve @ (alias) imports used inside a libary

Webpack is throwing this error: Module not found: Error: Can't resolve '@/utils/index'. So, here's the nippy rundown: This failing import above is made within the node library vue2-datepicker. This ...
0
votes
0answers
18 views

Is module loading in Nodejs deterministic?

I'm trying to debug some Node.js code where there are several circular dependencies. It smells like an issue with modules being partially loaded due to the circular dependencies (the errors are all of ...
0
votes
1answer
71 views

How to use es6 import instead of require?

I want to use import in my file, but I cant find the way to replace my require properly See the code I want to replace const object = { first: require('../example/first.json').EXL.PUBLIC, second:...
0
votes
2answers
56 views

Can't call setState

I have had to change my code from using fetch to require within my react app for use within electron. Since doing so I have got the following error: Warning: Can't call setState on a component that ...
0
votes
1answer
30 views

Change from using fetch to fs.readFile or require

I am unable to use fetch within our react app due to it being packaged within electron. I am trying to find a way to modify what we have to either use fs.readFile or require. From what I have read it ...
0
votes
1answer
76 views

Getting “Invalid call” when using require with Typescript and Expo

I am trying to play some audio in a react-native app created with the expo-cli. The code is written in typescript and the offending code looks like this, taken from the expo.io documentation: import ...
0
votes
0answers
229 views

How to fix warning “the request of a dependency is an expression” for every imported Angular component i try to use?

I have tried to use the following two zoom/scroll components for my Angular project. https://www.npmjs.com/package/@durwella/zoomable-canvas https://www.npmjs.com/package/ngx-image-zoom + 2 others I ...
-4
votes
1answer
22 views

I can't inlcude autoload.php file in my home.php file?

I can't inlcude autoload.php file in my home.php file. Any help please ?Screenshot
0
votes
1answer
22 views

Requires of three files are giving me three of the same objects

I am importing three js modules that I made into a program but whenever I run any of them, they always run the exported function of the last imported file. x = require("./modules/x/x"); y = require("....
-1
votes
1answer
25 views

Undefined variable error although the variable IS present in an already included file [duplicate]

I have a PHP script named constants.php constants.php:- <?php $projectRoot = "path/to/project/folder"; ... ?> And then I have another file named lib.php lib.php:- <?php class Utils { ...
0
votes
1answer
20 views

centralize the repeated code into a single file

language nodejs I have a bulky code, which is repeated the same way in many files: file1.js, file2.js, file3.js, ..., each file has a different instance of the same class, the only difference is the ...
0
votes
1answer
95 views

require and module.exports : TypeError: X is not a function

File structure : server ├── controllers │   ├── locationsController.js │   ├── mainController.js │   └── utilisateursController.js ├── models │   ├── Locations.js │   ├── Utilisateurs.js | └── ... ├...
-1
votes
2answers
117 views

const fs = require(“fs”) not working correctly on Node js

This is my first post here so i apologise if i make an error. I am having an problem when trying to use const fs = require("fs") in Node js. Visual Studio code IDE is not recognising it as being ...
1
vote
1answer
124 views

Getting error “module: identifier already required in doc” when importing code

In my Racket program, I get the error message: "module: identifier already required in doc" when I try to require code from a file that I've written. But when I copy and paste the code into the ...
0
votes
0answers
18 views

PHP require properly includes script, but it's contents are seemingly not being read

I am trying to require some configuration files that, for security reasons, are outside of any directory accessible through the web. The location of the file is /var/www/config/admin.php. require '/...
0
votes
0answers
13 views

Pear mail package require_once

Im having trouble when trying to use the mail library of PEAR, im including it like this: namespace App\Commands\GeneralCommands; use App\Http\Controllers\Msg\MsgController; use Illuminate\Http\...
1
vote
1answer
33 views

When load the electron renderer,What is the different about the require between http:// and file://?

I run an electron app by running electron ./dist/main.js In the electron renderer-process, I load a webpage and run require('lodash') in the webpage. When I load the webpage by http://, I can't get ...
1
vote
0answers
41 views

React component AMD bundling with Webpack for Require.js

Due to some reason, we want to load React component on Backbone view (with Require.js). This React component is being bundled using Webpack 4.x. We have enable AMD/UMD mode during bundling in Webpack ...
1
vote
2answers
44 views

Does requiring from the standard library make a program slower?

I’m thinking of ruby specifically when I ask this question, but if the answer is language-agnostic, I’d like to know as well. I often require from the ruby standard library, namely fileutils, open3, ...
0
votes
1answer
36 views

Why won't Namespaces Work in a PHP required file? [duplicate]

This question may sound stupid to many of you, still have I been unable to find any clue in the docs (I did RTFM). When you set a php variable in a php file and then make use of it in a file you ...
3
votes
2answers
2k views

cordova-plugin-crypt-file - requireCordovaModule error

I just upgrade Cordova to version 9. It cased plugin cordova-plugin-crypt-file to stop working - when I build the application, I get error Using "requireCordovaModule" to load non-cordova module "...
0
votes
0answers
29 views

kendoDropDownList() is not a function with requireJs

Hello I have this js file where I define the dependencies define(["jquery", "core", "dropdown", "bootstrap"], function ($, kendo, kendoDropDownList, bootstrap) { console.log(kendo); $("#testCont")...
0
votes
0answers
15 views

Getting 500 error and last Console.log() is not getting printed in Node js Routes file

I am getting internal server 500 error and also the Last Console.log() is not getting printed in the following code... Here is brief of my project set up... it is Project generated by using express-...
0
votes
1answer
31 views

How to ignore one of multiple return values from require in JavaScript?

I have a require statement like this const {_Api, JsonRpc, _RpcError} = require('eosjs'); I am not using the underscored variables. But I am getting no-unused-vars warning for them. How can I ignore ...
0
votes
1answer
47 views

How to deal with require() files inside a node_module?

I am quite new to node_moduels. For instance, say you have this structure: The app directory your_app/node_modules/your_module your_app/app.js The module directory your_module/index.js lib/...