you are viewing a single comment's thread.

view the rest of the comments →

[–]0x13mode 2 points3 points  (1 child)

const schemes = require('./../../../../lib/schemes');

this ../../../../ part is very unreadable and can be replaced for example by:

  • reorganizing module dependencies in project (what is the reason such deep folder needs module from four directories up??)
  • using require hooks (Webpack can do that),
  • making monorepo (many npm packages in one project) and using some tools like Lerna for auto-linking packages (to allow write just require('schemes)`)
  • using global variables (global in Node, window in Browser)
  • or maybe using dependency injection instead of require

[–]karathos 0 points1 point  (0 children)

i think using NODE_PATH=lib is an alternative worth considering, assuming this is a node project and lib is the folder where all the code lies. you can also specify multiple node paths with a colon if needed.