If an explicit cwd is provided, try searching for the module there if it could otherwise not be determined
See original GitHub issueThe current implementation chooses to search for the module in the following order:
- <
configPath
directory>/node_modules/<module name> - main file in <
configPath
directory>/package.json
I have a need for the search to continue. Perhaps if these first two searches turn out unsuccessful, these 2 steps could be repeated in the CWD (in place of the configPath
) if an explicit one was provided. So the process would be to search for the module in the following order:
- <
configPath
directory>/node_modules/<module name> - main file in <
configPath
directory>/package.json - <provided
cwd
>/node_modules/<module name> - main file in <provided
cwd
>/package.json
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Command-line parameter to force "module" instead ... - GitHub
I'm aware that I can name a file with .mjs or set "type": "module" in package.json. I'm also aware of the --input-type=module CLI...
Read more >How can I import a module dynamically given the full path?
The python path can contain zip archives, "eggs" (a complex kind of zip archives), etc. Modules can be imported out of them. So...
Read more >subprocess — Subprocess management — Python 3.11.1 ...
The subprocess module allows you to spawn new processes, connect to their ... If capture_output is true, stdout and stderr will be captured....
Read more >Python Tutorial - File and Text Processing
When a module is loaded in Python, __file__ is set to the module name. Try running this script with various __file__ references and...
Read more >query, download and build perl modules from CPAN sites
If it is a module, CPAN determines the distribution file in which this ... only lists directories explicitly asked for, for example FOO/*...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is true, but is not the case when a
configPath
is set.In my specific situation, I have a
configPath
file that is version controlled in directoryA
and want to run it in context of directoryB
which is not version controlled. DirectoryB
contains my target library in the node_modules directory. I expected that when I pass both theconfigPath
and thecwd
that it would search for my target library in directoryB
since I explicitly told it that I am working there. What happens instead is that it only tries to look for the target library in directoryA
. This is becauseconfigBase
is defined and so the said line of code (https://github.com/js-cli/js-liftoff/blob/master/index.js#L93) chooses to assignconfigBase
to thebasedir
property. The node_modules aren’t there and neither is a package.json file. This directs to code to https://github.com/js-cli/js-liftoff/blob/master/index.js#L110 where themodulePath
is never assigned.I realize that in most cases the
configPath
file will be co-located with the target library, but I also see no harm in searching thecwd
path after theconfigPath
directory is searched and the code failed to locate an appropriatemodulePath
.I’ve ran into the same problem with the following directory layout:
Grunt uses LiftOff these days like the following:
But had the same problem in the past on its own as well. The workaround then was to simply set the current working dir of the process:
With switching to LiftOff this doesn’t work anymore and the current working directory is not recognized during searching for modules, even though it’s provided on the shell using
--base
(or even--cwd
). But one can work around that usingpackage.json
in theconfig
-dir: That file is always checked in case aconfigBase
is available, but a requested module has not been found and only needs to contain the following in my directory layout: