fix(plugins): clean up leftover files after plugin uninstall#2458
fix(plugins): clean up leftover files after plugin uninstall#2458dirkwa wants to merge 1 commit intoSignalK:masterfrom
Conversation
|
Grateful Dirk!! There just might be one other thing to check, due to testing I have been forced to remove the node-modules folder and re-create it by npm install, and that makes the signalk-fusion-device directory pop-up agaian. Thinking there is some residual inside npm, not beeing a nodejs developer so limited understanding but the package.json in -signalk lists these dependencies...
|
When npm remove fails silently, the plugin directory remains in node_modules and the dependency stays in package.json. On next npm install, the "removed" plugin gets reinstalled. Add cleanupAfterRemove() that runs after npm remove completes: - Removes leftover node_modules/<package> directory - Removes the dependency from package.json - Clears Node.js require cache for the removed module - Deletes plugin config file and data directory
3377a19 to
cdde2a3
Compare
|
Good catch, I updated it and now it should remove the dependency even if the remove silently falls. |
Background
Discord User Tore Dahl repored the issue that a plugin is not removed properly.
https://discord.com/channels/1170433917761892493/1481926436335124633
Summary
When
npm removefails silently, the plugin directory remains innode_modules/and the dependency stays inpackage.json. On server restart the plugin loads as if never removed, and runningnpm install(e.g. after deletingnode_modules/) reinstalls it.Adds
cleanupAfterRemove()that runs afternpm removecompletes to handle this scenario:node_modules/<package>directorypackage.jsonFixes the issue reported by @torevalley where uninstalled plugins reappeared after
npm install.Manually Tested