0

I have certain files in my TypeScript project that are frequently used by many files throughout the hierarchy of the project - modules like helper functions or configuration. I end up needing to apply a very long string in the import statements. For example:

import config from '../../../../../path/to/configFile';

Is there a way to configure a project to make files like that available like ones from the node_modules folder with short paths? So, in the above example, I'll simply have to type:

import config from 'my-config-module';

I don't want to put these files in the node_modules folder because I don't want to have to remember to put them in there every time I delete the folder and reinstall it. Was just wondering if such a thing is possible in Node (or TypeScript)...

user2921009
  • 711
  • 1
  • 10
  • 21
  • You can add a step to whatever build/deployment script you use that copies your shared modules to the `node_modules` directory. This could be added as part of whatever script compiles your TypeScript files into JS files. – jfriend00 Sep 11 '21 at 03:59
  • Yes! That's exactly the type of solution I was looking for. Thanks Jeff. – user2921009 Sep 12 '21 at 01:43

0 Answers0