Questions tagged [module]

A logical subdivision of a larger, more complex system.

Modules are a convenient way to break down a larger problem and divide it into smaller problems/solutions. This way the main problem can be broken down into separate parts that can be worked on independently. For example, one module could consist of a the printing functionality of program, which can be handed to one programmer. The GUI (Graphical User Interface) could be another module, handed to another programmer, and so forth.

Modular design is meant to improve efficiency and speed of development by allowing programmers to work on specific aspects of the program independently of each other.

22551 questions
71
votes
3 answers

How to import a .hs file in Haskell

I have made a file called time.hs. It contains a single function that measures the execution time another function. Is there a way to import the time.hs file into another Haskell script? I want something like: module Main where import…
Jonno_FTW
  • 8,601
  • 7
  • 58
  • 90
70
votes
3 answers

Can I know, in node.js, if my script is being run directly or being loaded by another script?

I'm just getting started with node.js and I have some experience with Python. In Python I could check whether the __name__ variable was set to "__main__", and if it was I'd know that my script was being run directly. In that case I could run test…
Hubro
  • 56,214
  • 69
  • 228
  • 381
70
votes
2 answers

What's the purpose of `Object.defineProperty(exports, "__esModule", { value: !0 })`?

I read minimized tensorflow.js file for understanding module structure. Tensorflow.js is written in typescript and the above file(link) may be result of transpiling. Anyway, I understood this module written with IIEF pattern for UMD module format.…
Hyuck Kang
  • 1,671
  • 2
  • 16
  • 24
70
votes
7 answers

How to make one module depend on another module artifact?

I have maven multiple-module project. A: parent. B: child1. C: child2. B will be packaged to get jar file and then c will use this jar file to compile the code. In B, if I run mvn package, it will create b.jar (stays in B/target/jars not…
David
  • 3,538
  • 9
  • 39
  • 50
70
votes
19 answers

How to install bcmath module?

How do I install the bcmath module on a server? I tried yum update php-bcmath but it said it found nothing.
JDesigns
  • 2,284
  • 7
  • 25
  • 39
70
votes
2 answers

ES6 modules: Export single class of static methods OR multiple individual methods

I'm using ECMAScript6 modules. What is the correct way to export/import multiple methods from a module from the options below? Single class of static methods: //------ myClass.js ------ export default class myClass { static myMethod1() { …
umpljazz
  • 1,182
  • 4
  • 11
  • 21
70
votes
5 answers

How to remove module after "require" in node.js?

Let say, after I require a module and do something as below: var b = require('./b.js'); --- do something with b --- Then I want to take away module b (i.e. clean up the cache). how I can do it? The reason is that I want to dynamically load/ remove…
murvinlai
  • 48,919
  • 52
  • 129
  • 177
69
votes
5 answers

How can I install a CPAN module into a local directory?

I'm using a hosted Linux machine so I don't have permissions to write into the /usr/lib directory. When I try to install a CPAN module by doing the usual: perl Makefile.PL make test make install That module is extracted to a blib/lib/ folder. I…
Ram
  • 3,034
  • 11
  • 38
  • 46
69
votes
4 answers

How to use npm modules in browser? is possible to use them even in local (PC)?

I'm new to npm module and node.js so it is really difficult to me. I have a js code whit many points and for each one of them I want to get the nearest city. To do this, in other question (Reverse geocoding with big array is fastest way? -…
Borja
  • 3,359
  • 7
  • 33
  • 66
69
votes
6 answers

How do I reload a module in an active Julia session after an edit?

2018 Update: Be sure to check all the responses, as the answer to this question has changed multiple times over the years. At the time of this update, the Revise.jl answer is probably the best solution. I have a file…
Colin T Bowers
  • 18,106
  • 8
  • 61
  • 89
68
votes
3 answers

In Rust, what is the purpose of a mod.rs file?

In some Rust projects I've seen (i.e pczarn/rustboot), I've seen mod.rs files in directories for whatever reason. I've not been able to find documentation about this, and I've seen it in many other Rust projects. What is the purpose of a mod.rs…
Liam Marshall
  • 1,353
  • 1
  • 12
  • 21
68
votes
3 answers

How to import a Python module from a sibling folder?

I have gone through many Python relative import questions but I can't understand the issue/get it to work. My directory structure is: Driver.py A/ Account.py __init__.py B/ Test.py __init__.py Driver.py from B import…
Joshua
  • 1,516
  • 2
  • 22
  • 31
67
votes
5 answers

When to use `require`, `load` or `autoload` in Ruby?

I understand the subtle differences between require, load and autoload in Ruby, but my question is, how do you know which one to use? Other than being able to "wrap" a load in an anonymous module, require seems to be preferred. But then autoload…
Mark W
  • 2,522
  • 3
  • 18
  • 21
67
votes
9 answers

Powershell import-module doesn't find modules

I'm learning PowerShell and I'm trying to build my own module library. I've written a simple module XMLHelpers.psm1 and put in my folder $home/WindowsPowerShell/Modules. When I do: import-module full_path_to_XMLHelpers.psm1 It works. But when I…
Serge Weinstock
  • 1,235
  • 3
  • 12
  • 20
67
votes
12 answers

How to check if a module is installed in Python and, if not, install it within the code?

I would like to install the modules 'mutagen' and 'gTTS' for my code, but I want to have it so it will install the modules on every computer that doesn't have them, but it won't try to install them if they're already installed. I currently have: def…
Foxes
  • 1,137
  • 3
  • 10
  • 19