react-sweet-progress icon indicating copy to clipboard operation
react-sweet-progress copied to clipboard

Error on import

Open meymeynard opened this issue 7 years ago • 6 comments

Hello. I'm encountering this error when importing the style.css

Uncaught Error: Cannot find module 'react-sweet-progress/lib/style.css'

My component looks like this:

import { Progress } from 'react-sweet-progress'
import 'react-sweet-progress/lib/style.css'

class ProgressModal extends Component {
  render () {
    const { onCloseModal } = this.props
    return (
      <Fragment>
        <ModalBody>
          <Progress percent={88} status='active' />
        </ModalBody>
        <ModalFooter>
          <button disabled onClick={onCloseModal}>
            Please wait a moment
          </button>
        </ModalFooter>
      </Fragment>
    )
  }
}

meymeynard avatar Oct 16 '18 09:10 meymeynard

Check node_modules/react-sweet-progress/lib is there style.css ?

nickbullll avatar Oct 17 '18 15:10 nickbullll

I have style.css in node_modules/react-sweet-progress/lib but i have this error Unable to resolve "react-sweet-progress/lib/style.css"

Martialdelastic avatar Oct 18 '18 13:10 Martialdelastic

Are you using webpack?

If so, can you provide your webpack config file here.

nickbullll avatar Nov 12 '18 19:11 nickbullll

Hi @abraztsov, I don't mean to hijack this issue but I'm having an import issue as well.

I'm getting

ERROR in ./node_modules/react-sweet-progress/lib/style.css 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
> .react-sweet-progress {
|   display: -ms-flexbox;
|   display: flex;
 @ ./src/components/gifteeOnboarding/GifteeOnboardingForms.js 27:0-45
 @ ./src/components/gifteeOnboarding/GifteeOnboardingApp.js
 @ ./src/index.js

my webpack config:

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader"
        }
      }
    ]
  }
};

any idea what I might try to fix this?

ahhh I think I got it, just added this and looks like it's working:

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader"
        }
      },
      {
        test: /\.css$/,
        use: [
          { loader: "style-loader" },
          { loader: "css-loader" },
        ],
      }
    ]
  }
};

dfarrel1 avatar Nov 14 '18 01:11 dfarrel1

@dfarrel1 I'm getting the same issue, where to add the code which you have shared above. I am using in react-native android

yuvaraj119 avatar Nov 14 '18 13:11 yuvaraj119

That was a webpack config. If you’re not using webpack then I’m not sure how you fix the issue. You did get a different error though, as shown in the original post on this thread. Not sure it’s the same issue I had.

dfarrel1 avatar Nov 15 '18 18:11 dfarrel1