Skip to content
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

remark cannot find globally installed presets #199

Closed
Kristinita opened this issue Feb 7, 2019 · 9 comments
Closed

remark cannot find globally installed presets #199

Kristinita opened this issue Feb 7, 2019 · 9 comments
Labels
🙋 no/question This does not need any changes

Comments

@Kristinita
Copy link

Kristinita commented Feb 7, 2019

#165 — possibly related issue.

1. Summary

I don't understand, how I can use globally installed remark plugins. Variant from documentation doesn't work for me.

2. Argumentation

I want to use remark not only for JavaScript projects. I can use remark for projects in another programming languages and just for my notes. I don't think, that adding many node_modules for each project is a good idea.

3. Data

No locally installed remark plugins.

  • KiraRemark.md:
* Kira

[Goddess][]
  • .remarkrc.yaml:
plugins:
  preset-lint-recommended:

4. Steps to reproduce

  • npm install --global remark-cli remark-preset-lint-recommended
  • remark KiraRemark.md

5. Expected behavior

User can use only .remarkrc.yaml configuration file → all globally installed plugins will work.

6. Actual behavior

  • basic:
D:\SashaDebugging>remark KiraRemark.md
KiraRemark.md
  1:1  error  Error: Could not find module `preset-lint-recommended`
    at addModule (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\remark-cli\node_modules\unified-engine\lib\configuration.js:242:27)
    at use (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\remark-cli\node_modules\unified-engine\lib\configuration.js:203:7)
    at addIn (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\remark-cli\node_modules\unified-engine\lib\configuration.js:197:7)
    at addPreset (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\remark-cli\node_modules\unified-engine\lib\configuration.js:166:9)
    at merge (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\remark-cli\node_modules\unified-engine\lib\configuration.js:150:5)
    at Config.create (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\remark-cli\node_modules\unified-engine\lib\configuration.js:105:5)
    at done (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\remark-cli\node_modules\unified-engine\lib\find-up.js:148:20)
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:54:3)

× 1 error

I try:

  • remark KiraRemark.md --use preset-lint-recommended
  • remark KiraRemark.md --rc-path ".remarkrc.yaml"
  • remove .remarkrc.yaml and remark KiraRemark.md --use preset-lint-recommended

Same error.

7. Environment

  • Windows 10 Enterprise LTSB 64-bit EN
  • Node.js 11.9.0
  • remark-cli 6.0.1
  • remark-preset-lint-recommended 3.0.2

Thanks.

@wooorm
Copy link
Member

wooorm commented Feb 10, 2019

Super weird! This should not be like the issue you mentioned: one preset should work fine globally.
If the readme example doesn’t work, I’m thinking that this is related to your environment. Maybe a Windows issue?

What happens if you try remark KiraRemark.md --use remark-preset-lint-recommended (no config file?).

Could you provide a list of globally installed packages, so I can debug?

@wooorm wooorm changed the title bug(plugins): globally installed plugins remark cannot find globally installed presets Feb 10, 2019
@Kristinita
Copy link
Author

@woorm,

1. nodeenv

I can't reproduce the problem, use nodeenv:

D:\SashaDebugging>nodeenv kira_remark_env
 * Install prebuilt node (11.9.0) .. done.
symbolic link created for kira_remark_env\Scripts\nodejs.exe <<===>> node.exe
 * Install npm.js (latest) 

D:\SashaDebugging>"kira_remark_env/Scripts/activate.bat"
(kira_remark_env) D:\SashaDebugging>npm install --global remark-cli remark-preset-lint-recommended
D:\SashaDebugging\kira_remark_env\Scripts\remark -> D:\SashaDebugging\kira_remark_env\Scripts\node_modules\remark-cli\cli.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules\remark-cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ remark-preset-lint-recommended@3.0.2
+ remark-cli@6.0.1
added 287 packages from 196 contributors in 87.392s

(kira_remark_env) D:\SashaDebugging>remark KiraRemark.md
-   Kira

[Goddess][]
KiraRemark.md
       1:1  warning  Missing newline character at end of file  final-newline            remark-lint
       1:3  warning  Incorrect list-item indent: add 2 spaces  list-item-indent         remark-lint
  3:1-3:12  warning  Found reference to undefined definition   no-undefined-references  remark-lint

 3 warnings

2. Usage without config

Same error:

D:\SashaDebugging>remark KiraRemark.md --use remark-preset-lint-recommended
KiraRemark.md
  1:1  error  Error: Could not find module `preset-lint-recommended`
    at addModule (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\remark-cli\node_modules\unified-engine\lib\configuration.js:242:27)
    at use (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\remark-cli\node_modules\unified-engine\lib\configuration.js:203:7)
    at addIn (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\remark-cli\node_modules\unified-engine\lib\configuration.js:197:7)
    at addPreset (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\remark-cli\node_modules\unified-engine\lib\configuration.js:166:9)
    at merge (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\remark-cli\node_modules\unified-engine\lib\configuration.js:150:5)
    at Config.create (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\remark-cli\node_modules\unified-engine\lib\configuration.js:105:5)
    at done (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\remark-cli\node_modules\unified-engine\lib\find-up.js:148:20)
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:54:3)

× 1 error

3. List of global packages

npm list -g --depth 0 > Kira_nodejs__global_packages_list.txt
  • Kira_nodejs__global_packages_list.txt
C:\Users\SashaChernykh\AppData\Roaming\npm
+-- @commitlint/[email protected]
+-- @commitlint/[email protected]
+-- @commitlint/[email protected]
+-- @prettier/[email protected] (github:prettier/plugin-python#0aa2517f4d22f55f8c4f5a7d2c6c3caaa807503c)
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]

Thanks.

@wooorm
Copy link
Member

wooorm commented Feb 10, 2019

Wait, so your first example (### 1. nodeenv) shows that with a config file, it works? But when passing a plugin in with --use doesn’t?

What happens if you use nodeenv with the second example? (### 2. Usage without config)

@kortina
Copy link

kortina commented Feb 18, 2019

I am trying similarly to use remark with a global install and it cannot find any plugins, even though I have indeed installed them.

npm list -g | grep remark
├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ ├─┬ [email protected]
├─┬ [email protected]
│ └─┬ [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ └─┬ [email protected]
├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ ├─┬ [email protected]

.remarkrc:

  "plugins": [
    "remark-reference-links",
    "remark-lint"
  ]
}

Error:

DEBUG="*" remark _posts/2019-02-07-napkin-modeling-the-us-govt-p-l.md -u reference-links
  unified-engine:configuration Looking for `.remarkrc,.remarkrc.js,.remarkrc.yml,.remarkrc.yaml` configuration files +0ms
  unified-engine:configuration Looking for `remarkConfig` fields in `package.json` files +3ms
  unified-engine:find-up No files found for `/Users/kortina/src/kortina.github.io/_posts/2019-02-07-napkin-modeling-the-us-govt-p-l.md` +0ms
  unified-engine:file-set-pipeline:stdin Ignoring `streamIn` +0ms
  unified-engine:file-pipeline:read Reading `/Users/kortina/src/kortina.github.io/_posts/2019-02-07-napkin-modeling-the-us-govt-p-l.md` in `utf8` +0ms
  unified-engine:file-pipeline:read Read `/Users/kortina/src/kortina.github.io/_posts/2019-02-07-napkin-modeling-the-us-govt-p-l.md` (err: null) +4ms
  unified-engine:find-up Read file `/Users/kortina/src/kortina.github.io/.remarkrc` +10ms
  unified-engine:file-pipeline:configure Using settings `{}` +0ms
  unified-engine:file-pipeline:configure Using `3` plugins +0ms
  unified-engine:file-pipeline:configure Using plug-in `fail`, with options `undefined` +0ms
  unified-engine:file-pipeline:configure Using plug-in `fail`, with options `undefined` +0ms
  unified-engine:file-pipeline:configure Using plug-in `fail`, with options `undefined` +0ms
  unified-engine:file-pipeline:parse Parsing `_posts/2019-02-07-napkin-modeling-the-us-govt-p-l.md` +0ms
  unified-engine:file-pipeline:queue Queueing `_posts/2019-02-07-napkin-modeling-the-us-govt-p-l.md` +0ms
  unified-engine:file-pipeline:queue Flushing: all files can be flushed +0ms
  unified-engine:file-pipeline:stringify Not compiling failed document +0ms
  unified-engine:file-pipeline:copy Not copying +0ms
  unified-engine:file-pipeline:stdout Ignoring writing to `streamOut` +0ms
  unified-engine:file-pipeline:file-system Ignoring writing to file-system +0ms
_posts/2019-02-07-napkin-modeling-the-us-govt-p-l.md
  1:1  error  Error: Could not find module `remark-reference-links`
    at addModule (/usr/local/lib/node_modules/remark-cli/node_modules/unified-engine/lib/configuration.js:242:27)
    at use (/usr/local/lib/node_modules/remark-cli/node_modules/unified-engine/lib/configuration.js:203:7)
    at addEach (/usr/local/lib/node_modules/remark-cli/node_modules/unified-engine/lib/configuration.js:188:9)
    at addPreset (/usr/local/lib/node_modules/remark-cli/node_modules/unified-engine/lib/configuration.js:164:9)
    at merge (/usr/local/lib/node_modules/remark-cli/node_modules/unified-engine/lib/configuration.js:150:5)
    at Config.create (/usr/local/lib/node_modules/remark-cli/node_modules/unified-engine/lib/configuration.js:105:5)
    at done (/usr/local/lib/node_modules/remark-cli/node_modules/unified-engine/lib/find-up.js:148:20)
    at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)

✖ 1 error```

@kortina
Copy link

kortina commented Feb 19, 2019

I was just testing on another machine, from a fresh start, and I followed the README exactly and ran into similar issue.

From instructions via: https://github.com/remarkjs/remark/blob/master/doc/getting-started.md

$ npm install --global remark-cli remark-html remark-preset-lint-markdown-style-guide
$ echo "_Hello_." > readme.md # create the example file from the instructions
$ remark readme.md --use html --use preset-lint-markdown-style-guide
readme.md
  1:1  error  Error: Could not find module `html`
    at addModule (/usr/local/lib/node_modules/remark-cli/node_modules/unified-engine/lib/configuration.js:242:27)
    at use (/usr/local/lib/node_modules/remark-cli/node_modules/unified-engine/lib/configuration.js:203:7)
    at addIn (/usr/local/lib/node_modules/remark-cli/node_modules/unified-engine/lib/configuration.js:197:7)
    at addPreset (/usr/local/lib/node_modules/remark-cli/node_modules/unified-engine/lib/configuration.js:166:9)
    at merge (/usr/local/lib/node_modules/remark-cli/node_modules/unified-engine/lib/configuration.js:150:5)
    at Config.create (/usr/local/lib/node_modules/remark-cli/node_modules/unified-engine/lib/configuration.js:108:3)
    at done (/usr/local/lib/node_modules/remark-cli/node_modules/unified-engine/lib/configuration.js:78:25)
    at apply (/usr/local/lib/node_modules/remark-cli/node_modules/unified-engine/lib/find-up.js:185:7)
    at applyAll (/usr/local/lib/node_modules/remark-cli/node_modules/unified-engine/lib/find-up.js:175:7)
    at found (/usr/local/lib/node_modules/remark-cli/node_modules/unified-engine/lib/find-up.js:167:7)

✖ 1 error

Anyone got ideas on the root cause here?

@wooorm
Copy link
Member

wooorm commented Feb 19, 2019

@kortina Could you run your last example again with DEBUG="*" before it, and post the results?

@kortina
Copy link

kortina commented Mar 6, 2019

I tracked down the issue. There was a probably where I didn't have nodenv correctly prepended to my path, but I did have the nodenv binary on my path, so I think there was some sort of mismatch.

Once I added the following to my ~/.bash_profile and reinstalled, things worked as expected:

export PATH="$HOME/.nodenv/bin:$PATH"

@wooorm
Copy link
Member

wooorm commented Mar 8, 2019

Oh good find!
Alright, I’m guessing something similar is also the problem for @Kristinita: I think making sure the modules are somewhere in your path will fix it!

@wooorm wooorm closed this as completed Mar 8, 2019
@wooorm wooorm added the 🙋 no/question This does not need any changes label Aug 15, 2019
@bdlangton
Copy link

I had the same issue, but a different solution, so I just wanted to post here in case others see this.

I am on Mac. I didn't have $NODE_PATH set, so I had to add this: export NODE_PATH="/usr/local/lib/node_modules"

That fixed it. I added it to to my .zshrc file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 no/question This does not need any changes
Development

No branches or pull requests

4 participants