Comments (10)
Thanks for the bug report.
Just so I'm clear, your folder structure looks like this?
~/
my-app/
index.js
node_modules/
foo/
node_modules/
bar/
So I guess foo
is getting resolved, but bar
is not found?
from devtool.
I have modules in:
~/modules/my-module/node_modules
~/root/node_modules
~.node_modules
And I'm trying to run my-module
devtool is somewhere in ~/.nvm/....
Modules outside of the ~/modules/my-module/node_modules
result in the above error.
from devtool.
Here is how Node load modules from node_modules
It searches in the .node_modules
as well.
This is my development setup and it won't be easy for me to change it like it's suggested in the docs.
from devtool.
I don't think that should work. As it says in the docs, it just looks up folders recursively until it sees a node_modules
folder. If it reaches the top (~/
) before that, then it fails.
In your case, it should only look inside ~/node_modules
. So you should not be able to resolve my-module
like that.
from devtool.
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.
from devtool.
I just ran a test with node v4 and node isn't finding modules in ~/root/node_modules/
. Is that your $HOME
or something?
And yeah, it seems like an Electron bug since this happens even without the devtool
require hooks.
from devtool.
It's all in my $HOME ~
, it points to my user's home folder. All of my files are in my home folder.
From the docs:
For example, if the file at '/home/ry/projects/foo.js' called require('bar.js'), then Node.js would look in the following locations, in this order:
/home/ry/projects/node_modules/bar.js /home/ry/node_modules/bar.js /home/node_modules/bar.js /node_modules/bar.js
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.
from devtool.
Hmm wait. All my paths are actually symbolic links, so the actual paths are as follows:
mighty@sky:/media/SSD/Dropbox/code/modules/sql-admin$
mighty@sky:/media/SSD/node_modules$
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.
from devtool.
Ok, so it seems that only the ~.node_modules
path isn't working.
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 /media/SSD/tmp/devtool.js
have no problem finding the /media/SSD/node_modules/extend/index.js
which is UP one level, but finding the /home/mighty/.node_modules
is a problem because the path has already been resolved.
Great job anyway, the tool is looking really good!
from devtool.
Thanks for testing. 😄
Hopefully we can figure out a fix for the ~/.node_modules
path.
from devtool.
Related Issues (20)
- Module version mismatch. Expected 50, got 51. HOT 5
- Fails on save when using mongoose 4.x with sub-documents
- Require hook for ts-node doesn't work HOT 3
- V8 flag `--expose-gc` causes whole config to silently fail
- Reload console on file change with --watch
- Windows 10: File /npm/node_modules/devtool/index.html not found HOT 1
- Add flag to disable process.exit() HOT 1
- impossible to inspect http requests
- Devtool Chrome debugger cannot find prototype closure functions
- Ignore files when using --watch HOT 5
- Devtools doesn't work with dynamic link libraries
- REPL :: On windows (10) i can't require modules from current working directory HOT 1
- Can you add docs on how to use this with jest? HOT 1
- Support more flags in devtoolrc
- install error HOT 1
- add support async/await HOT 3
- please update new electron version
- Unable to install
- devtool with expressjs, how to find script files?
- devtool/bin/spawn replacement in Node/DevTool? Looking for advice ... HOT 1
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 devtool.