Search code examples
javascriptreactjsbulma

After sync on gitlab code unable to compile and show no error in files but on webpage


The error it shows on webpage- Failed to compile

src/pages/Adminstration/IdentityAccess/CreateUserType.jsx
Syntax error: Unexpected token (31:2)

  29 |           <main>
  30 |             <div className="container">
> 31 | <<<<<<< HEAD:src/web/src/pages/Adminstration/IdentityAccess/NewUserType.jsx
       |  ^
  32 |               <Breadcrumb {...{ context: "MANAGE_USERTYPES", leaf: "New User Type" }} />
  33 | =======
  34 |               <Breadcrumb {...{ context: "MANAGE_USER_TYPES", leaf: "new User Types" }} />

When I check code in file it is-

import React, { Component } from "react";
import { Header, Sidebar, Breadcrumb } from "../../../components";
import { startLoading, stopLoading } from "../../../components/Util";
import Select from "react-select";

class CreateUserType extends Component {
  constructor(props) {
    super();
    this.state = {
      loaded: true,
    };
  }

  componentDidMount() {
    document.title = "LIMS - Create User Types ";
  }

  upsert() {
    console.log("TBD....");
  }

  render() {
    !this.state.loaded ? startLoading() : stopLoading();
    return (
      this.state.loaded && (
        <div>
          <Header />
          <Sidebar context="USER_TYPES" />
          <main>
            <div className="container">
            <Breadcrumb {...{ context: "MANAGE_USERTYPES", leaf: "New User Type" }} />
              <h5 className="subtitle is-3">User Type</h5>
              <hr />

Someone has changed the filename from NewUserType.js to CreateUserType so I changed the file name everywhere.


Solution

  • This is the product of a failed git merge, which is the default strategy Git makes when updating your local repository. If you see this, that means there are conflicts in a file, and it will always be a set format:

    The line (or lines) between the lines beginning with <<<<<<< and ====== are what you already had in your local copy of the repository (HEAD points to your current branch or commit):

    > 31 | <<<<<<< HEAD:src/web/src/pages/Adminstration/IdentityAccess/NewUserType.jsx
           |  ^
      32 |               <Breadcrumb {...{ context: "MANAGE_USERTYPES", leaf: "New User Type" }} />
      33 | =======
    

    The line (or lines) between the lines beginning with ======= and >>>>>>> are what was pulled from the remote repository (where you git pull from) and is different to what Git expects to be in your file:

      33 | =======
      34 |               <Breadcrumb {...{ context: "MANAGE_USER_TYPES", leaf: "new User Types" }} />
      35 | >>>>>>>
    

    You should pick the one which has the most relevance to your project (or projects) and ensure that you do not have any modified files when you do a git pull (google for git stash to find out about that)