importing and exporting modules in react
I'm working in a React.js project which I need to import some JavaScript in others, and some others I have to export it.For example I have A.js which needs some library:var EventEmitter =...
View ArticleRequire function returning an empty Object in NodeJS [closed]
I have 2 files to import an add function i made and execute it**math.js **function add (a,b){ return a + b; } module.export = add();Node1.jsconst math = require("./math.js");console.log(marh(2,5);i was...
View ArticleDifference between require, include, require_once and include_once?
In PHP:When should I use require vs. include?When should I use require_once vs. include_once?
View ArticleUncaught Reference error: require is not defined [duplicate]
Below code cause this issue return iconLists.reduce((list, name) => { const pL = list; pL[name] = require(`./svg/${name}.svg`) return pL }, {})}tried different plugins no luck.vite.config.jsimport...
View ArticleHow to create a NPM package installed globally to run code from terminal with...
I created a javascript with node to rewrite javascricp file to make all require to import and my code do it perfectly. My NPM package is named require2import.it's here on Github.If run my script from...
View Articlerequire is not defined in js file that compiled from typescript file
Hello,I am currently working on a Firebase project, and it was working fine until I converted the JavaScript code to TypeScript. Since then, I’ve encountered many problems. I resolved most of the...
View ArticleVuejs access to file outside of the application
I have several files on my server located at /var/www/files/My vuejs is in ~/Dev/appI did : let file = require('/var/www/files/myfile.jpg')then npm run build my app.But I have this error 🫣 :Error:...
View ArticleFix ruby project inconsistent files using zeitwerk
For a large (non-Rails) ruby project with thousands files not following naming convention for class, module and constants that uses a lot require and require_relative and potential circular dependency,...
View ArticleHow to have aliases with nodejs import
I have a project using node.js v16, and more and more npm libs are not anymore compatible with require, and need to be used with import.Until now i was using package.json to have my root directory as...
View ArticleWhy is my Apache require by IP not working for a subdirectory?
I want the index page of example.com to be public and the /col directory to be restricted. The IP shown is what appears in my apache log file so I know it's my IP.<Directory...
View ArticleHow to "require" a LUA script within a Spoon-package?
We have base LUA file ~/.hammerspoon/init.lua which can load a spoon package:hs.loadSpoon("Foo")Now we have our package file init.lua by path:~/.hammerspoon/Spoons/Foo.Spoon/init.luaIt works fine.I...
View ArticleImport a library into a chrome extension content script?
I am looking to import a library into one of my chrome extension's content scripts. Lets take chart.js for instance.I've already looked at this post, but I'm not sure if it is what I need. If it is,...
View ArticleError: Failed to open stream: No such file or directory
I have this code and the same twilio.php library running on both a local (XAMPP) server and a VPS:checkConnection.php<?php // Include Twilio PHP Library here require...
View ArticleCpanel React js dynamic site not running
I am trying to run my dynamic node react js web app on cpanel. But as I try and 'run js script' of npm run dev I get this error message...returncode: 1stdout:vite-project@0.0.0 dev...
View Articlerequire() empty string id error on non-empty strings
When I try to run my js code there appears to be an error that shouldn't exist no matter what.Basically i loop through an array of strings (paths), i try to import an object (using require) using each...
View ArticleSyntax for using math.js in typescript file
I am writing an office 365 addin using typescript. I am trying to use functions from math.js. In my home.html head tag, I have the line:<script...
View ArticleWhat is the 'import * as ...' equivalent for require?
When using the ES6 import command, you can use an alias to import all functions from a file, for example:import * as name from "module-name";Is there an equivalent way to do this using require,...
View ArticleHow to use --exec option in nestjs command
I'm trying to use the --exec option to run a command before the nestjs server start (--require).I want to modify the start:dev script in my package.jsonBut I can not make it work, always got an...
View Articleis there a require for json in node.js
I would like to include a couple of JSON files in my JavaScript code that are in the same directory as my JavaScript source file.If I wanted to include another JavaScript file I could simply use...
View ArticleIs it possible to clear node.js require cache using express.js?
I wrote node.js small app for myself which was using small js code to clear require cache before handling request:let clearCacheif (process.env.NODE_ENV === 'development') { const {cache} = require...
View Article