Is there a way to do that without using any npm libraries.
The answer to that sort of thing is always "yes" because those libraries are written in JavaScript.
I would warmly recommend against it and for standard approaches (like using yarn workspaces and declaring age as a proper local npm module) but you can always do something like a require hook:
const originalRequire = Module.prototype.require;
Module.prototype.require = function moduleRequire(id) {
if(id === 'age') {
return require('./modules/age');
}
return originalRequire.call(this, id);
}
Or add your local modules folder to the NODE_PATH environment variable so it finds it there.
Neither of these are good options and I recommend against both of them.
It is better to stick to the standard modus operandi and vendor and consume "proper" npm modules.
node_moduleslocation, in an expected global location or use a path to indicate where to load it from.require()works is all in that doc reference I gave you. If you want justrequire('age')to find it, I think you will have to put its path inNODE_PATHor replace/hookrequire()to give it new behaviors. Based on the doc, I don't see any other way. I would argue that you're doing something wrong in your design when you have this problem. This is not how node.js was built to run and you're trying to sub-vert it somehow.