0

prtScn I'm trying to start new react app and I have a problem. im using visual studio code , and follows the instructions: in the visual code terminal :

create-react-app sali (sali is the name)
npm install 
 node node_modules\webpack\bin\webpack.js -d -w

and then i get this message:

ERROR in ./src/index.js 7:16
Module parse failed: Unexpected token (7:16)
You may need an appropriate loader to handle this file type.
| import * as serviceWorker from './serviceWorker';
|
> ReactDOM.render(<App />, document.getElementById('root'));
|
| // If you want your app to work offline and load faster, you can change

here is the code:(this is the default code of create react app) index.js

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';

ReactDOM.render(<App />, document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
serviceWorker.unregister();

app.js

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

class App extends Component {
  render() {
    return (
      <div className="App">
        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <p>
            Edit <code>src/App.js</code> and save to reload.
          </p>
          <a
            className="App-link"
            href="https://reactjs.org"
            target="_blank"
            rel="noopener noreferrer"
          >
            Learn React
          </a>
        </header>
      </div>
    );
  }
}

export default App;

package.json

{
  "name": "sali",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.5.2",
    "react-dom": "^16.5.2",
    "react-scripts": "2.0.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "webpack-cli": "^3.1.2"
  }
}

Please, what is wrong?

2
  • Have you tried to run just npm run build or npm run start instead of calling wepback directly? Commented Oct 15, 2018 at 6:30
  • After a clean create-react-app even a npm start should be enough. Did you try it? Commented Oct 15, 2018 at 7:42

1 Answer 1

1

I guess that what you wrote in your terminal is

> create-react-app sali
> npm install 
> node node_modules\webpack\bin\webpack.js -d -w

With Create-React-App, this is not what you are supposed to do, you should do :

> create-react-app sali
> cd sali
> npm run start

And you should read React documentation and tutorials because they will be of a good help !

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

Comments

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.