NodeJS

Fix Relative Paths in NodeJS Apps

Most NodeJS apps consist of hundreds of .js files which are included wherever needed using require. While this makes the dependencies of modules really obvious, most of the paths look like this in the end: const createUuid = require('../../../support/utils/create_uuid'); The problem is that by default NodeJS uses relative paths for local modules (not stuff that’s inside the node_modules folder). Not only does this look really strange, it’s also hard to read and if you ever want to move files around you have to fix all paths in your application to make it work again (and since this is lazily evaluated, you’ll probably miss some for code paths that are not tested).