Skip to content

Error when running from GitLab CI #34

@theletterf

Description

@theletterf

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions