Comments (5)
@ariporad I'm almost certain that the line require('app-module-path').addPath(__dirname);
still needs to be in the entry point of your NodeJS application due to how the app-module-path
module hooks into the module loader.
If I have multiple entry points then add that line to each entry point file. For example if your application can be ran via node server.js
and node build.js
then add that line to server.js
and build.js
.
If you know of a way to modify app-module-path
so that it can add a search path directory while in a non-entry point file then please let us know. Otherwise, I think we can close this issue with the answer that putting require('app-module-path').addPath(__dirname);
in setup.js
in your example will not work. You will need to add that line to index.js
.
from app-module-path-node.
I'm working on a test for it, I'll let you know tomorrow morning.
Thanks!Ari
On Mon, Sep 7, 2015 at 7:58 PM, Phillip Gates-Idem
[email protected] wrote:
@ariporad I'm almost certain that the line
require('app-module-path').addPath(__dirname);
still needs to be in the entry point of your NodeJS application due to how theapp-module-path
module hooks into the module loader.
If I have multiple entry points then add that line to each entry point file. For example if your application can be ran vianode server.js
andnode build.js
then add that line toserver.js
andbuild.js
.If you know of a way to modify
app-module-path
so that it can add a search path directory while in a non-entry point file then please let us know. Otherwise, I think we can close this issue with the answer that puttingrequire('app-module-path').addPath(__dirname);
insetup.js
in your example will not work. You will need to add that line toindex.js
.Reply to this email directly or view it on GitHub:
#6 (comment)
from app-module-path-node.
I just tested it, it appears to work. You can see the results here: https://github.com/ariporad/test-app-module-path-in-setup-file
from app-module-path-node.
@ariporad maybe I'm missing something but your test project doesn't have a setup.js
file. The line that uses app-module-path
is in src/index.js
which I assume is the entry point. Is this what you intended for your test?
from app-module-path-node.
I would actually expect it to work since app-module-path
walks up the require tree to update the paths for already loaded parent modules using the following code:
app-module-path-node/lib/index.js
Lines 38 to 41 in a9831ce
That was a later code change, but it is something that is supported. So to answer your question: Yes, it can be in a setup.js
file.
I'm going to go ahead and close this issue, but feel free to comment or open another issue if you have other questions or concerns. Thanks.
from app-module-path-node.
Related Issues (20)
- How to make this module work with mocha? HOT 1
- Can't load `constants` HOT 1
- clarification on 'additional directories'
- it not working in node_modules? HOT 2
- Can't find `package.json` HOT 5
- Fix for applications installed globally HOT 7
- require node_modules before try to require local files HOT 1
- specify how this works in readme.md HOT 3
- Implement option to choose v1.X or v2.X behaviour
- unable to resolve my modules
- How about variables in paths?
- Please add a LICENSE file HOT 1
- Module loading not happening HOT 1
- Cannot add path '../modules'? HOT 2
- ES6 support
- Jest HOT 2
- give error with ziet/pkg
- npm i bitcoinjs-lib HOT 1
- not working with module package
- How to get vscode intellisense??
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from app-module-path-node.