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 with import components #352

Closed
alejandoing opened this issue Oct 3, 2018 · 6 comments
Closed

Error with import components #352

alejandoing opened this issue Oct 3, 2018 · 6 comments

Comments

@alejandoing
Copy link

alejandoing commented Oct 3, 2018

Hi. I've had problems with import components. Someone can you help me?

For example, when I try import this component:

import { IconLink } from 'components'

I get this error:

Module not found: Can't resolve 'components'

My index.js file:

const req = require.context('.', true, /\.\/[^/]+\/[^/]+\/index\.js$/)

req.keys().forEach((key) => {
  const componentName = key.replace(/^.+\/([^/]+)\/index\.js/, '$1')
  module.exports[componentName] = req(key).default
})
@diegohaz
Copy link
Owner

diegohaz commented Oct 3, 2018

What command triggers that error? How can we reproduce it?

@alejandoing
Copy link
Author

alejandoing commented Oct 3, 2018

My HomePage component:

import React from 'react'
import styled from 'styled-components'
import { font, palette } from 'styled-theme'
import { IconLink } from 'components'

const Title = styled.h1`
  font-family: ${font('primary')};
  color: ${palette({ primary: 3 }, 1, true)};
  text-align: center;
`

const HomePage = () => {
  return (
    <div>
      <Title palette="primary">Hello World!</Title>
      <IconLink to="/" icon="arc" height={100} />
    </div>
  )
}

export default HomePage

The error is generated in this line:

import { IconLink } from 'components'

The same error happens in other components. What could be?

@diegohaz
Copy link
Owner

diegohaz commented Oct 3, 2018

Got it. But how this error occurs? Is this a plugin on your editor? Are you running a command (npm run something) etc.?

@alejandoing
Copy link
Author

The error is produced when run this command npm run start

@diegohaz
Copy link
Owner

diegohaz commented Oct 3, 2018

This can be your webpack/babel configuration. Does this happen for you on a clean fork of ARc? Otherwise, could you provide a repository where this happens?

@alejandoing
Copy link
Author

Thanks. I have made a new clean installation and not it works perfect. Surely it was a mistake in the configuration of my webpack.

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

2 participants