question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Import markdown.md for notes "Cannot find module"

See original GitHub issue

Describe the bug I want to use the notes addon to display relevant information about my component using markdown, see code below.

import mdNotes from './card.component.notes.md';

storiesOf('Atoms/Card', module)
  .add('Default with notes', () => ({
    component: CardComponent
  }), {
    notes: mdNotes
  }
);

Unfortunatly this results in TS2307: Cannot find module './card.component.notes.md'.

To Reproduce Steps to reproduce the behavior:

  1. Create a new story
  2. Create a markdown file with some content
  3. Import markdown file in your story
  4. See error

Expected behavior Markdown file is included and content is correctly rendered in the notes tab.

Code snippets

card.component.notes.md

# Card component
This component uses the Angular Material library.

typings.d.ts

declare module '*.md' {
  const content: string;
  export default content;
}

tsconfig.json

"typeRoots": [
      "node_modules/@types",
      "node_modules/@types","./typings.d.ts"
    ],

System:

  • OS: Windows 10 Pro
  • Device: Lenovo Thinkpad
  • Browser: Firefox
  • Framework: Angular
  • Addons: Notes
  • Version: 5.0.5

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

36reactions
kroedercommented, Apr 6, 2019

I just opened a PR with a fix, just follow my changes https://github.com/storybooks/storybook/pull/6444/files

It works in every possible scenario for me, can you verify that?

  1. Add typings.d.ts in .storybook image
declare module '*.md' {
  const content: string;
  export = content;
}
  1. Add it to files in .storybook/tsconfig.json
{
  "extends": "../src/tsconfig.app.json",
  "compilerOptions": {
    "types": [
      "node"
    ]
  },
  "exclude": [
    "../src/test.ts",
    "../src/**/*.spec.ts",
    "../projects/**/*.spec.ts"
  ],
  "include": [
    "../src/**/*",
    "../projects/**/*"
  ],
  "files": [
    "./typings.d.ts"
  ]
}
10reactions
JacekKoscieszacommented, Dec 8, 2019

This worked for me (https://stackoverflow.com/a/56659180/602860):

Create a globals.d.ts file in your root directory with the following code:

declare module "*.md";
Read more comments on GitHub >

github_iconTop Results From Across the Web

import markdown.md for addons "Cannot find module" #2883
Issue details I want to use markdown.md with addons but I can't import it Steps to reproduce I got error import README1 from...
Read more >
How to import markdown(.md) file in typescript - Stack Overflow
I'm in Angular 13. This works to a point. I get an error: Error: Module not found: Error: Can't resolve 'raw-loader'.
Read more >
markdown-it - npm
Start using markdown-it in your project by running `npm i markdown-it`. ... on script load // Note, there is no dash in "markdownit"....
Read more >
Getting Started | Markdown Guide
Markdown is a fast and easy way to take notes, create content for a website, and produce print-ready documents. It doesn't take long...
Read more >
Wiki - GitLab Docs
GitLab wikis support Markdown, Rdoc, AsciiDoc, and Org for content. Wiki pages written in ... Cannot find the link to the wiki from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found