Comments (16)
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.
from remark.
Are both mdast and mdast-html global in your example case?
Yes, they are.
from remark.
Just noticed that in my case mdast
was npmlinked. After removing the link and doing npm i mdast -g
global plugins are working again.
Perhaps mdast should also consult npm prefix as a last step if none of other patterns match. What do you think?
from remark.
Seems to not be very simple: https://github.com/h2non/requireg#differences-with-require
from remark.
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...
from remark.
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:
If the NODE_PATH environment variable is set to a colon-delimited list of absolute paths, then io.js will search those paths for modules if they are not found elsewhere.
[…]Additionally, io.js will search in the following locations:
1: $HOME/.node_modules
2: $HOME/.node_libraries
3: $PREFIX/lib/nodeWhere $HOME is the user's home directory, and $PREFIX is io.js's configured node_prefix.
These are mostly for historic reasons.
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 require()
algorithm works just fine!
$ echo 'module.exports=function(){return function(ast){ast.children.push({"type":"text","value":"hi there"})}}' >~/.node_libraries/hello.js
$ echo '# hello' |mdast -u hello
# hello
hi there
<stdin>: no issues found
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:
Global installs on Unix systems go to {prefix}/lib/node_modules. Global installs on Windows go to {prefix}/node_modules (that is, no lib folder.)
And so there are only two paths currently missing: {prefix}/lib/node_modules
and {prefix}/node_modules
.
from remark.
That makes things better. Know if it's easy to access that prefix reliably, sync?
from remark.
First of all, npmrc needs to be taken into account, you can use rc
for that.
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 path.resolve(process.execPath, '..')
according to the docs.
from remark.
Cool! Any reason why the windows case is not handled by your module?
from remark.
It is handled in 1.0.1 :)
from remark.
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.
from remark.
One idea is to check if process.argv[1]
is {prefix}/bin/mdast
({prefix}/mdast
on Windows). That is not very pretty though.
Alternatively, if __dirname
is under {prefix}
, then mdast is definitely global (but in this case it could be not installed directly by the user, and this test also fails if mdast is linked).
from remark.
I haven’t checked this on Windows. Are you able to test there?
I opted for checking if process.argv[1]
is inside $prefix
, which seemed like the simplest check for this.
I tested in npm-run scripts, and with using a linked mdast(1).
I think this should work 😄
from remark.
I haven’t checked this on Windows. Are you able to test there?
Nope, sorry.
from remark.
Darn, well, I think this should work. So let’s leave it at that!
from remark.
👍
from remark.
Related Issues (20)
- When I use 'remark-gfm 'to parse the table, it will get stuck HOT 2
- Option to use two spaces instead of backslash for hard line break HOT 15
- Request cutting out a new release HOT 2
- Error "document is not defined" when running in browser extension background HOT 2
- A stringifier option to control escaping HOT 8
- Please consider support for multi-row Headers for Tables HOT 2
- Multiple spaces in list items HOT 4
- Ampersand in link query strings unexpectedly escaped with backslash HOT 5
- remark-parse: `(` in strong block will broke the block HOT 7
- Footnotes do not work within mermaid diagrams HOT 2
- How to display incomplete PHP code outside of a code block HOT 4
- Unified v11 has been released, can remark be updated to support it? HOT 4
- New release with updated dependencies HOT 8
- TypeError: this.getData is not a function HOT 4
- `Compile` not set when used as a unified plugin HOT 4
- [remark-parse] Ordered lists are not recognized if they both use leading zeroes and interrupt a block HOT 11
- Remark plugin is un-escaping content HOT 4
- HTML entity is mangled HOT 4
- Thematic break after image is parsed as an heading level 2 HOT 3
- remark-cli no longer allows using multiple plugins via the `--use` parameter HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from remark.