Skip to content

Missing gray-matter dependency in @vuepress/shared-utils #1190

@jdoubleu

Description

@jdoubleu
  • I confirm that this is a issue rather than a question.

Bug report

I am using the @vuepress/markdown-loader package in another project.
This package requires @vuepress/shared-utils.

The parseFrontmatter.ts file requires the gray-matter module which is not present in the package.json of @vuepress/shared-utils.

Version

$ npm list | grep -2  @vuepress/markdown-loader
└─┬ @vuepress/[email protected]
  ├─┬ @vuepress/[email protected]
  │ ├─┬ @vuepress/[email protected]

Steps to reproduce

  1. Create a package that requires @vuepress/markdown-loader (e.g. npm install @vuepress/markdown-loader)
  2. Install webpack: npm install webpack webpack-cli
  3. Add a Markdown file (e.g. Example.md)
  4. Configure webpack to use the markdown file as entry and the the markdown-loader to compile it:
const path = require('path')

module.exports = {
    entry: path.resolve(__dirname, 'Example.md'),
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'file.js'
    },
    module: {
        rules: [
            {
                test: /\.md$/,
                use: [
                    {
                        loader: require.resolve('@vuepress/markdown-loader'),
                        options: {
                            sourceDir: path.resolve('chapters')
                        }
                    }
                ]
            }
        ]
    }
}
  1. Run webpack

What is expected?

The markdown loader compiles all Markdown files.

What is actually happening?

Webpack throws the following warnings:

WARNING in ./Example.md
Module build failed (from ../@vuepress/markdown-loader/index.js):
Error: Cannot find module 'gray-matter'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Module.require (internal/modules/cjs/loader.js:657:17)
    at require (/path/to/project/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at parseFrontmatter (/path/to/project/node_modules/@vuepress/shared-utils/lib/parseFrontmatter.js:2:18)
    at Object.module.exports (/path/to/project/node_modules/@vuepress/markdown-loader/index.js:41:23)
 @ ./ sync nonrecursive \.md$ ./Example.md
 @ ./index.js

Other relevant information

  • Your OS: macOS
  • Node.js version: v11.6.0
  • Browser version: n/a
  • Is this a global or local install? local
  • Which package manager did you use for the install? npm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions