Reputation: 1148
I have a .TS file where I store all of my utility functions that I use in alot of my projects (kind of like my own private lodash) However every time I want to use this I have to manually copy and paste this file into the project that I am working on. I also know how to use node to make scripts and write to the file system using FS, my question is how do I make this node script available globally without having to specify ".js" so I can use it in the terminal like this: "node loadLibrary"?
TL;DR
How do I make .js files available to node globally so I do not have to specify the path and just call the script by name EX: "node loadLibrary"
Upvotes: 0
Views: 89
Reputation: 51
Maybe you could create Git Repository with the functions.
In the projects you want to import the functions you can do:
npm install --save https://github.com/foo/bar.git
/* your code */
import { helperFunc } from 'bar';
Upvotes: 2
Reputation: 21
Have you considered just making it an npm package? Might not be the exact solution you were thinking of, but it would certainly be easy.
Upvotes: 1