PSGraph
PSGraph copied to clipboard
Node cmdlet conflicts with node.js command name
When PSGraph is installed, trying to execute node.js commands will instead autoload load the PSGraph module and overshadow calls to node.
This specific conflict is something I have been concerned about but haven't seen it been much of an issue. I have two ideas for a permanent fix, but it abuses the mechanics of PowerShell in a way that could be fragile and need a lot of testing. Not sure when I would get to it based on my current commitments.
I do have a few options you can do in the meantime to get unblocked:
- The first hack you can do to is to edit the .psd1 file in the module and set
FunctionsToExport = "*"
This will stop auto loading for that module and you will have to call import-module or use #requires statements to load it.
-
Or you could turn off all module auto loading with $PSModuleAutoloadingPreference='None'
-
A third option is to not install the module but Save-Module to a different location and import it from that folder when you need it.
Hey, thanks for looking at this. Both propositions are fine (I lean toward the first one) but I do have a question:
Why not simply prefix all module commands, eg: node > New-PSGNode, Row > New-PSGRow etc?
EDIT:Typo
I implemented this module as a DSL and selected names that made sense in the context of creating graphs. It would be a breaking change at this point. But here are my options.
-
rename the commands and add aliases with the old names. Using an alias will not auto-import a model, but it will still collide after import.
-
Move the commands to the local scope of the graph command. This would remove them from the exported functions and they would only be valid when nested inside the graph command. Would break intellesense and possibly script analyzer. Would be hard to test.
-
Making those commands private may work as well as #2 without the issues related to testing (but still have the other issues.
-
Move the commands into a nested module that is imported into the parent scope when the main module is imported. They would not auto load on their own and not be part of the functions to export but would conflict after loading. Basically the same as #1 with different implementation.
-
Disable auto loading. Require the module to be explicitly loaded any time it should be used. This would be done by setting FunctionsToExport = "*".
As long as the graph command is still exported and auto loads the module, then the risk of breaking existing scripts is low as node is always used with graph.
I can optionally only fix node without touching the other graphing commands.
IMHO, the module is a niche so you should pick up option 5 or only fix node without touching the other graphing commands.