This is tad long but I\'ll need the code example to illustrate my confusion. After which I am interested to the answer for the following:
re
All the answers here about aliases and opts.paths
/$NODE_PATH
are not great because that approach is a deprecated part of the module system in node and browserify, so it could stop working at any time.
You should learn how the node_modules algorithm works so you can effectively organize your code in a way that plays well with nested node_modules
directories.
There is a section in the browserify handbook that covers avoiding ../../../../../../.. relative path issues. It can be summarized as:
node_modules/
or node_modules/app
so that you can require('yourmodule')
or require('app/yourmodule')
depending on which you prefer.Don't use opts.path
/$NODE_PATH
. It makes your project: