Closed rkoshak closed 1 year ago
That’s a good idea.
install it in a way that npm won't delete it when updating packages.
Creating a new folder for your personal library inside node_modules
should work, right?
Editing files inside the folders of npm packages of course isn’t a good idea …
when their personal library gets wiped out when openHABian runs an update.
openHABian checks for updates and the runs npm update package-name
, so openHABian should only modify the openhab
and openhab_rules_tools
folders.
Creating a new folder for your personal library inside node_modules should work, right?
Nope. Well, it'll work until you run npm update
at which point your module won't be in the .json file and npm
will helpfully remove it.
openHABian checks for updates and the runs npm update
, so openHABian should only modify the openhab and openhab_rules_tools folders.
It should but in practice this command too will delete stuff that isn't "installed". Even installing a new library will cause the non-installed modules to be removed.
To get around this, based on the best practices I could figure out, one needs to develop the library outside of the node_modules folder. Then you have some options but the easiest is to tar up your library and use npm
to install your library from the tar file. That sets everything up so that the personal library is installed and therefore npm
won't remove it.
Okay, thanks for the information. That‘s definitely something to add to the README.
With the addition of
openhab_rules_tools
to openHABian, I think we need to add a libraries section to the docs under Advanced. There we should explain how to properly create a personal library and install it in a way that npm won't delete it when updating packages. Otherwise I imagine some users will become unhappily surprised when their personal library gets wiped out when openHABian runs an update.We can link to and depend on generic npm tutorials for the most part but I think it's worth the warning because a lot of users will just start editing files under node_modules which is going to cause a problem.