Giter Club home page Giter Club logo

Comments (10)

mattdesl avatar mattdesl commented on July 3, 2024

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.

simov avatar simov commented on July 3, 2024

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.

simov avatar simov commented on July 3, 2024

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.

mattdesl avatar mattdesl commented on July 3, 2024

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.

simov avatar simov commented on July 3, 2024

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.

mattdesl avatar mattdesl commented on July 3, 2024

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.

simov avatar simov commented on July 3, 2024

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.

simov avatar simov commented on July 3, 2024

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.

simov avatar simov commented on July 3, 2024

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.

devtool

Great job anyway, the tool is looking really good!

from devtool.

mattdesl avatar mattdesl commented on July 3, 2024

Thanks for testing. 😄

Hopefully we can figure out a fix for the ~/.node_modules path.

from devtool.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.