S
S
Sergey Topolov2020-05-10 22:49:10
JavaScript
Sergey Topolov, 2020-05-10 22:49:10

How to assign CommonJS module loading to a variable in Bash?

I don't understand Bash yet. I just wanted to learn how to make an NPM module. made it to be used via a file connection. but then I also wanted to make it possible to execute it through the console.

the problem is this. I can call scripts and get the output of their execution

example: I
run the file "run.sh"

this code will be executed there
node -e 'require("./node_modules/@topus009/perf/x.js")'
but there is no such
var= $ { node -e "require('./node_modules/@topus009/perf/x.js')" }
error - bad substitution

is how it should work:

a function is exported inside a loadable module. loading the module. I make some bash scripts and then I call this module.

but I don’t know how easy it is to get a module for further use and launch.
how to write the module body to a variable. stackoverflow didn't help.

5eb85a9c14361983130886.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question