3

Any information would be really helpful ,Initially i ran the npm install babel-loader command as well.

I have

ERROR in ./app-client.js Module build failed: SyntaxError: /Users/dawatramani/ReactNodejs/app-client.js:

Unexpected token (4:13)

  2 | var APP= require('./components/APP');
  3 | 
> 4 | React.render(<APP />,document.getElementById('react-container'));
    |              ^
  5 | 

at Parser.pp.raise (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/location.js:22:13) at Parser.pp.unexpected (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/util.js:89:8) at Parser.pp.parseExprAtom (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/expression.js:522:12) at Parser.pp.parseExprSubscripts (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/expression.js:277:19) at Parser.pp.parseMaybeUnary (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/expression.js:257:19) at Parser.pp.parseExprOps (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/expression.js:188:19) at Parser.pp.parseMaybeConditional (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/expression.js:165:19) at Parser.pp.parseMaybeAssign (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/expression.js:128:19) at Parser.pp.parseExprListItem (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/expression.js:1046:16) at Parser.pp.parseCallExpressionArguments (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/expression.js:353:20) at Parser.pp.parseSubscripts (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/expression.js:316:31) at Parser.pp.parseExprSubscripts (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/expression.js:287:15) at Parser.pp.parseMaybeUnary (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/expression.js:257:19) at Parser.pp.parseExprOps (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/expression.js:188:19) at Parser.pp.parseMaybeConditional (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/expression.js:165:19) at Parser.pp.parseMaybeAssign (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/expression.js:128:19) at Parser.pp.parseExpression (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/expression.js:92:19) at Parser.pp.parseStatement (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/statement.js:163:19) at Parser.pp.parseBlockBody (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/statement.js:529:21) at Parser.pp.parseTopLevel (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/statement.js:36:8) at Parser.parse (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/parser/index.js:129:19) at parse (/Users/dawatramani/ReactNodejs/node_modules/babel-core/node_modules/babylon/lib/index.js:47:47) at File.parse (/Users/dawatramani/ReactNodejs/node_modules/babel-core/lib/transformation/file/index.js:517:34) at File.parseCode (/Users/dawatramani/ReactNodejs/node_modules/babel-core/lib/transformation/file/index.js:603:20) at /Users/dawatramani/ReactNodejs/node_modules/babel-core/lib/transformation/pipeline.js:49:12 at File.wrap (/Users/dawatramani/ReactNodejs/node_modules/babel-core/lib/transformation/file/index.js:563:16) at Pipeline.transform (/Users/dawatramani/ReactNodejs/node_modules/babel-core/lib/transformation/pipeline.js:47:17) at transpile (/Users/dawatramani/ReactNodejs/node_modules/babel-loader/index.js:14:22) at Object.module.exports (/Users/dawatramani/ReactNodejs/node_modules/babel-loader/index.js:88:12)

2 Answers 2

2

Well with current versions of reactJS you shouldn't use React.render() but rather use ReactDOM.render() and import ReactDOM from "react-dom". I think this will solve your problem.

ReactDOM.render(<ComponentName />,document.getElementById('react-container'));

This is a very recent change introduced with 0.14. React is now split into a core library and the DOM adapter. Rendering is now done via ReactDOM.render.

DOCS

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot :) :) The issue got resolved by using ReactDOM.render() instead of React.render().
0

It seems like you forgot paste a Component in render method :)

React.render(,document.getElementById('react-container'));

1 Comment

use ReactDOM.render instead React.render

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.