node.js - NodeJS - Having trouble reloading external js? -
i trying build sort of plugin manager can reload external source files on fly without shutting down node app. quick proof of concept eval'd plugin files functions being prototyped class. seemed work great, except cant seem scoping right. functions evaluated , prototyped, im not sure why functions cant grab global vars. have advice on this?
rather manually loading file, rely on require
.
now, problem require has internal cache , load modules once. however, can force unload quick workaround:
delete require.cache[require.resolve(myplugin)]; require(myplugin);
Comments
Post a Comment