-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Require files outside of the project's node_modules folder #6
Comments
Thanks for the bug report. Just so I'm clear, your folder structure looks like this?
So I guess |
I have modules in:
And I'm trying to run Modules outside of the |
Here is how Node load modules from node_modules It searches in the This is my development setup and it won't be easy for me to change it like it's suggested in the docs. |
I don't think that should work. As it says in the docs, it just looks up folders recursively until it sees a In your case, it should only look inside |
Here is how I run my module: mighty@sky:~/modules/sql-admin$ node index.js Here is how I run it using devtool: mighty@sky:~/modules/sql-admin$ devtool index.js -s I have modules located UP in the file system tree: mighty@sky:~/modules/sql-admin/node_modules$
mighty@sky:~/root/node_modules$
mighty@sky:~/.node_modules$ Node find modules in all three places, devtool does not. Node searches in the nearest node_modules folder first. Then it moves one level above and tries again. And this isn't something new. |
I just ran a test with node v4 and node isn't finding modules in And yeah, it seems like an Electron bug since this happens even without the |
It's all in my $HOME From the docs:
So this is exactly what is happening, Node searches up to the root of the directory tree. I'll take a further look at your code and I'll try to fix it. Otherwise devtool seems useful to me, but I can't use it that way. It might be something Electron related as well, because node-webkit for example requires all modules to be in the project's node_modules if I remember correctly. |
Hmm wait. All my paths are actually symbolic links, so the actual paths are as follows:
So they are in fact under the same directory. Anyway, the point being is that Node searches recursively up to the top until it finds the module. |
Ok, so it seems that only the It seems that the entry point (my example file) 1 (which is also located in a symbolic link location) is being resolved before generating all search paths in 2 that are the real paths. So my test file located in Great job anyway, the tool is looking really good! |
Thanks for testing. 😄 Hopefully we can figure out a fix for the |
👋 I have a bunch of modules required in my project that are outside of my project's node_modules folder, I know that's highly unusual, but that also works perfectly fine with Node because it looks for files in various places up to the file systems's root. However when I run my app through the devtool I get this error message:
That's a module that's not directly in my project's node_modules folder, it's a few levels up in the file system. So I'm suspecting that this is something Electron specific, but I'm not that familiar with it and have no clue.
The text was updated successfully, but these errors were encountered: