Skip to content

import local module  #19

@enieber

Description

@enieber

Environment

Develop

Description

I trying use the component docs to document one project with local module @style/base

Reproducible Demo

run this component with one module local to reproduce the error

code component

// @flow
/*
 imports of components

*/
import { color } from '@styles/base' // @style is local module in relative folder project

const style = (props: Object) =>
  StyleSheet.create({
    text: {
      justifyContent: 'center',
      color: color.primary,
    }
 })

class Text extends PureComponent<Props> {
  render() {
    const { value, type } = this.props
    const contextualStyle = style(this.props)
    
    return (
      <TextStyle
        type={props.type}
        style={contextualStyle.text}
      >
        {value}
      </TextStyle>
    )
  }
}

Documentation to component

export const meta = {
  title: 'Text compoenent'
}

import Text from './Text'

# Text component

the Text compoent has the props you need to use text in project


<Text
  value={'Enter your mobile number'}
/>

cli to run doc

yarn component-docs serve "**/*.{md,mdx}"

error result

internal/modules/cjs/loader.js:615
    throw err;
    ^

Error: Cannot find module '@styles/base'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:613:15)
    at Function.Module._load (internal/modules/cjs/loader.js:539:25)    at Module.require (internal/modules/cjs/loader.js:667:17)
    at require (internal/modules/cjs/helpers.js:20:18)    at Object.<anonymous> (/*_my_folder_component*/)
    at Module._compile (internal/modules/cjs/loader.js:738:30)    at Module._compile (/**/node_modules/pirates/lib/index.js:83:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:749:10)
    at Object.newLoader [as .js] (/**/node_modules/pirates/lib/index.js:88:7)
    at Module.load (internal/modules/cjs/loader.js:630:32)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

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