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

Failed to compile. #1

Closed
wulingmei opened this issue Aug 9, 2017 · 3 comments
Closed

Failed to compile. #1

wulingmei opened this issue Aug 9, 2017 · 3 comments

Comments

@wulingmei
Copy link

wulingmei commented Aug 9, 2017

iimport React from 'react';
import ReactAplayer from 'react-aplayer';

export default class MusicPlyer extends React.Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  playHandler() {
    console.log('on play');
  }

  pauseHandler() {
    console.log('on pause');
  }

  render() {
    const props = {
      "autoplay": true,
      "mutex": true,
      "preload": "metadata",
      "music": {
        "author": "Hans Zimmer/Richard Harvey",
        "url": "http://devtest.qiniudn.com/Preparation.mp3",
        "pic": "http://devtest.qiniudn.com/Preparation.jpg"
      }
    };

    return (
      <ReactAplayer {...props} onPlay={this.playHandler} onPause={this.pauseHandler}/>
    );
  }
}
Failed to compile.

./~/react-aplayer/src/react-aplayer.js
Module parse failed: /Users/zhangwei/Work/Github/wulingmei/node_modules/react-aplayer/src/react-aplayer.js Unexpected token (20:6)
You may need an appropriate loader to handle this file type.
|   render() {
|     return (
|       <div className="aplayer" ref={(el) => {
|         this.el = el;
|       }}></div>

@sabrinaluo
Copy link
Collaborator

What's your webpack version and your webpack config?

Do you have below config in your .babelrc file?

{
  "presets": ["es2015", "react"]
}

Do you have babel-preset-es2015, babel-preset-react installed as project devDependencies?

If you are creating a new APP, a quick solution would be to create your react app with https://github.com/facebookincubator/create-react-app

@wulingmei
Copy link
Author

我使用的就是create-react-app呢,

@sabrinaluo
Copy link
Collaborator

Should be fixed now, please update the version by running:

npm install react-aplayer

Let me know if there is still any issue, thanks. :)

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