-
-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ways to use global mdast plugins with CLI? #46
Comments
Are both mdast and mdast-html global in your example case? I agree that it should work, and it worked before, so this is indeed a bug. |
Yes, they are. |
Just noticed that in my case Perhaps mdast should also consult npm prefix as a last step if none of other patterns match. What do you think? |
Seems to not be very simple: https://github.com/h2non/requireg#differences-with-require |
Also: I don’t think many people will link mdast into global, so if for this to work 5+ paths need to be checked, I’d rather decline... |
In reality, there are not so many of them. From Node docs:
Note that (1) these paths are practically deprecated, (2) none of them is where npm puts modules upon global install, and (3) they are part of the Node core, so default
So this is not what this issue is about. It really is about paths used by npm but not native to the Node. From npm docs:
And so there are only two paths currently missing: |
That makes things better. Know if it's easy to access that prefix reliably, sync? |
First of all, npmrc needs to be taken into account, you can use In the past, this one-liner worked for me pretty well: rc('npm', null, []).prefix || path.resolve(process.execPath, '../..') Upd: On Windows default prefix should be |
Cool! Any reason why the windows case is not handled by your module? |
It is handled in 1.0.1 :) |
One last Q: I'd like to only load global plug-ins when mdast is global too. That prevents a local mdast from loading a global plugin (by throwing a helpful error). Any idea if and how that would be possible? I have no clue, maybe you do, but this looks important. |
One idea is to check if Alternatively, if |
I haven’t checked this on Windows. Are you able to test there? |
Nope, sorry. |
Darn, well, I think this should work. So let’s leave it at that! |
👍 |
What is the preferred way of using globally installed plugins with CLI?
It just worked before. I found two ways of working around it.
$(npm root -g)
in$NODE_PATH
:Both ways are somewhat clumsy. Is there a simpler way of doing that or some relevant configuration option?
The text was updated successfully, but these errors were encountered: