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

Error: Cannot find module remark-preset-lint-recommended #322

Closed
4 tasks done
nvuillam opened this issue Apr 27, 2024 · 8 comments
Closed
4 tasks done

Error: Cannot find module remark-preset-lint-recommended #322

nvuillam opened this issue Apr 27, 2024 · 8 comments
Labels
🤷 no/invalid This cannot be acted upon 👎 phase/no Post cannot or will not be acted on

Comments

@nvuillam
Copy link

Initial checklist

Affected packages and versions

v15.0.1

Link to runnable example

No response

Steps to reproduce

.remarkrc is the following

{
  "plugins": [
    "remark-preset-lint-recommended"
  ]
}

See MegaLinter failing job

https://github.com/oxsecurity/megalinter/actions/runs/8862094296/job/24334663734?pr=3516

It used to work in previous versions

Expected behavior

To work ^^

Actual behavior

The following error is triggered

Error: Cannot find module `remark-preset-lint-recommended`
at Function.<anonymous> (file:///node-deps/node_modules/unified-engine/lib/configuration.js:432:15)

Runtime

Node v17

Package manager

npm 8

OS

Linux

Build and bundle tools

Other (please specify in steps to reproduce)

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Apr 27, 2024
@ChristianMurphy
Copy link
Member

ChristianMurphy commented Apr 27, 2024

Welcome @nvuillam! 👋
Sorry you ran into a spot of trouble.

remark-cli and remark-preset-lint-recommended are working fine together https://stackblitz.com/edit/node-rgxynu
I'm not sure what version 15.0.1 refers to neither of those packages have release a version 15 yet.

Feel free to share a minimal reproducible example of the issue you are seeing, ideally in a sandbox.
From the brief look at megalinter, there looks like there is a lot of abstraction wrapping these in the linter, and it feels like the bug may be in that abstraction.

@ChristianMurphy ChristianMurphy added the 🙊 open/needs-repro This needs a reproduction label Apr 27, 2024

This comment has been minimized.

@nvuillam
Copy link
Author

@ChristianMurphy remark-lint is disabled in MegaLinter since... July 2022, maybe you have a hint of a major change that happened at that time ?

Maybe the way to find remark-preset-lint-recommended package if remarklink-cli is installed globally ?

It is installed the following way (but not in the projet, in a MegaLinter docker image custom folder): npm --no-cache install --ignore-scripts --omit=dev remark-cli remark-preset-lint-recommended

Here is how to version is retrieved, and the result

Linter version command: ['/node-deps/node_modules/.bin/remark', '--version']
Linter version result: 0 remark: 15.0.1, remark-cli: 12.0.0

@ChristianMurphy
Copy link
Member

maybe you have a hint of a major change that happened at that time?

A lot have happened.
There are changelogs with migration which document all of those.
I'd encourage reading them 🙂

/node-deps/node_modules/.bin/remark

This stands put to me, crossing folders to get at node modules could be messing with module resolution.

Try using an npm script or npx to run remark.

@remcohaszing
Copy link
Member

It is installed the following way (but not in the projet, in a MegaLinter docker image custom folder): npm --no-cache install --ignore-scripts --omit=dev remark-cli remark-preset-lint-recommended

So it’s neither installed globally, nor locally in the project. Instead, it is installed locally in another project. This is quite an edge case. remark-preset-lint-recommended is looked up both globally and from the current project. You’re suggesting it should additionally be looked up locally in the project where remark-cli is installed.

I’m not really for or against this personally. MegaLinter is better off installing packages globally by passing the --global flag to npm. I feel like the argument for supporting this would be stronger if MegaLinter pinned their dependencies using a lockfile.

Regardless of all this, I strongly recommend to specify the major version of packages to install.

@wooorm
Copy link
Member

wooorm commented Apr 29, 2024

If you install things somewhere, say, path/to/remark-whatever-package, you can use that:

{
  "plugins": [
    "path/to/remark-whatever-package/index.js"
  ]
}

Or, install things globally.
Or, install things locally.

@wooorm wooorm closed this as not planned Won't fix, can't repro, duplicate, stale Apr 29, 2024
@wooorm wooorm added the 🤷 no/invalid This cannot be acted upon label Apr 29, 2024

This comment has been minimized.

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually 🙊 open/needs-repro This needs a reproduction labels Apr 29, 2024
@nvuillam
Copy link
Author

Thanks for your responses :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤷 no/invalid This cannot be acted upon 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

4 participants