3 ms·
There are lots of workarounds. My preferred workaround isn't especially good, but it keeps me sane since I also hate having giant relative paths. https://gist.g
by jdc0589 13y ago
There are lots of workarounds. My preferred workaround isn't especially good, but it keeps me sane since I also hate having giant relative paths. https://gist.github.com/jdc0589/9115898 https://gist.github.com/jdc0589/9115898
Usage is as follows:
var pRequire("./projectRequire")(rootPathOfYourProject);
var MyModule = pRequire("~/lib/foo/bar/myModule");
It doesn't really buy you anything over `require("nameOfYourPackage/path/to/module")`, but I like the consistent "~" prefix across projects using the same scheme.
Moving things to their own NPM package is a great solution when its something re-usable that logically makes sense to exist on it's own, but that isn't the case most of the time.