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 when running from GitLab CI #34

Open
theletterf opened this issue Oct 22, 2024 · 0 comments
Open

Error when running from GitLab CI #34

theletterf opened this issue Oct 22, 2024 · 0 comments

Comments

@theletterf
Copy link

Hi there,

Using the pipeline-components/remark-lint image, I'm getting the following error when trying to run remark with the the frontmatter-schema plugin from a GitLab CI:

file.md
 error Cannot process file
  [cause]:
    Error: Cannot parse given file `.remarkrc.mjs`
    at file:///app/node_modules/unified-engine/lib/find-up.js:137:19
    at done (file:///app/node_modules/trough/lib/index.js:194:7)
  [cause]:
    Error: Cannot import `.remarkrc.mjs`
    at loadFromAbsolutePath (file:///app/node_modules/unified-engine/lib/configuration.js:543:11)
    at async Configuration.loadScriptOrModule (file:///app/node_modules/unified-engine/lib/configuration.js:286:5)
    at async Configuration.create (file:///app/node_modules/unified-engine/lib/configuration.js:244:15)
  [cause]:
    Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'remark-frontmatter' imported from /docs/.remarkrc.mjs
    at packageResolve (node:internal/modules/esm/resolve:845:9)
    at moduleResolve (node:internal/modules/esm/resolve:918:18)
    at defaultResolve (node:internal/modules/esm/resolve:1148:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:390:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:359:25)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39)
✖ 1 error

The main part of the job is as follows:

frontmatter_check:
  stage: check-and-lint
  image:
    name: registry.gitlab.com/pipeline-components/remark-lint:latest
  variables:
      GIT_DEPTH: 1
  script:
    - apk add --no-cache git > /dev/null 2>&1
    - npm install -g remark-frontmatter remark-lint-frontmatter-schema

I then run remark --rc-path .remarkrc.mjs file.md --quiet --ignore-pattern '**/includes/**'. My .remarkrc.mjs file has:

import remarkFrontmatter from 'remark-frontmatter';
import remarkLintFrontmatterSchema from 'remark-lint-frontmatter-schema';

const remarkConfig = {
  plugins: [
    remarkFrontmatter,

    [
      remarkLintFrontmatterSchema,
      {
        schemas: {
          './app/frontmatter.schema.yaml': [
            './app/**/*.md',
          ],
        },
      },
    ],
  ],
};

export default remarkConfig;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant