has already been exported. Exported identifiers must be unique.Babel babylon error

2.7k views Asked by At

I am .net developer i am new in nodejs enviroment I have a nodeJS project.It was work very well,I addes some feauture and I finished it.Then I deleted that project.Now I must install that project for add new feautures

So I took project code in a folder and then I use

npm install 

and then I use npm build and npm start build commands but it give that error after npm start build command

has already been exported. Exported identifiers must be unique.

I search for that error.I find that solution.I think Error is about babel/babylon

https://github.com/babel/babylon/releases/tag/v6.11.2

but I did not understand that solution.Should I download https://github.com/babel/babylon/releases/tag/v6.11.2 that babylon file to under node modules?But in my node modules folder there is no babylon here is my package.json How can I install that project to any folder?Just copy files and npm install is enough?

{
  "name": "react-seed",
  "version": "0.0.13",
  "description": "Seed project for React apps using ES6 & webpack.",
  "repository": "https://github.com/badsyntax/react-seed",
  "config": {
    "buildDir": "./build",
    "buildDirTests": "./build_tests",
    "devHost": "0.0.0.0",
    "devPort": 8000,
    "remoteHost": "http://yazilimsozluk.com"
  },
  "scripts": {
    "build": "set NODE_ENV=production&& npm run webpack",
    "clean": "rimraf $npm_package_config_buildDir && mkdir $npm_package_config_buildDir",
    "env": "env",
    "lint": "eslint --ext .js --ext .jsx ./app ./webpack && echo No linting errors.",
    "prebuild": "npm run clean",
    "pretest": "npm install && npm run lint",
    "pretest-travis": "npm install && npm run lint",
    "start": "set NODE_ENV=development && node dev-server ./webpack/config",
    "test": "NODE_ENV=test karma start --single-run",
    "test-dev": "NODE_ENV=test karma start",
    "test-travis": "NODE_ENV=test karma start --single-run",
    "webpack": "webpack --colors --progress --config ./webpack/config"
  },
  "dependencies": {
    "classnames": "^2.1.1",
    "hammerjs": "^2.0.4",
    "immutable": "^3.7.6",
    "intl": "^1.0.0",
    "intl-locales-supported": "^1.0.0",
    "jquery": "^2.1.4",
    "lodash": "^4.9.0",
    "materialize-css": "^0.97.5",
    "ms-signalr-client": "^2.2.2",
    "normalize.css": "^4.0.0",
    "react": "^0.14.8",
    "react-dnd": "^2.1.4",
    "react-dnd-html5-backend": "^2.1.2",
    "react-dnd-html5-touch-backend": "^1.5.0",
    "react-dnd-touch-backend": "^0.2.7",
    "react-dom": "^0.14.8",
    "react-flexgrid": "^0.7.0",
    "react-intl": "^2.0.0-rc-1",
    "react-redux": "^4.4.1",
    "redux": "^3.3.1",
    "redux-thunk": "^2.0.1",
    "superagent": "^1.3.0"
  },
  "devDependencies": {
    "autoprefixer": "^6.3.4",
    "babel-core": "^6.7.4",
    "babel-eslint": "^6.0.0",
    "babel-loader": "^6.2.4",
    "babel-plugin-rewire": "^1.0.0-rc-1",
    "babel-plugin-transform-decorators": "^6.6.5",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-polyfill": "^6.7.4",
    "babel-preset-es2015": "^6.6.0",
    "babel-preset-react": "^6.5.0",
    "babel-preset-stage-0": "^6.5.0",
    "babel-runtime": "^6.6.1",
    "chai": "^2.3.0",
    "compass-mixins": "^0.12.7",
    "css-loader": "^0.23.1",
    "eslint": "^2.5.1",
    "eslint-plugin-react": "^4.2.3",
    "expose-loader": "^0.7.0",
    "extract-text-webpack-plugin": "^1.0.1",
    "file-loader": "^0.8.1",
    "glob": "^7.0.3",
    "html-loader": "^0.4.3",
    "inline-environment-variables-webpack-plugin": "^1.1.0",
    "json-loader": "^0.5.1",
    "karma": "^0.12.31",
    "karma-chrome-launcher": "^0.1.12",
    "karma-cli": "0.0.4",
    "karma-mocha": "^0.1.10",
    "karma-mocha-reporter": "^1.0.2",
    "karma-phantomjs-launcher": "^0.1.4",
    "karma-sinon": "^1.0.4",
    "karma-source-map-support": "^1.0.0",
    "karma-sourcemap-loader": "^0.3.4",
    "karma-webpack": "^1.5.1",
    "mocha": "^2.2.4",
    "mocha-loader": "^0.7.1",
    "node-libs-browser": "^1.0.0",
    "node-sass": "^3.4.2",
    "postcss-loader": "^0.8.2",
    "react-hot-loader": "^1.2.7",
    "rimraf": "^2.3.3",
    "sass-loader": "^3.2.0",
    "sinon": "^1.14.1",
    "source-map-support": "^0.4.0",
    "style-loader": "^0.13.1",
    "template-html-loader": "0.0.3",
    "webpack": "^1.12.14",
    "webpack-dev-server": "^1.8.2"
  },
  "engines": {
    "node": ">=0.10.0"
  },
  "eslintConfig": {
    "env": {
      "browser": true,
      "node": true,
      "es6": true
    },
    "ecmaFeatures": {
      "modules": true,
      "jsx": true
    },
    "globals": {
      "describe": true,
      "it": true,
      "xit": true,
      "xdescribe": true,
      "beforeEach": true,
      "sinon": true
    },
    "plugins": [
      "react"
    ],
    "parser": "babel-eslint",
    "rules": {
      "strict": true,
      "indent": [
        2,
        2
      ],
      "quotes": [
        2,
        "single"
      ],
      "new-cap": 0,
      "no-unused-expressions": 0,
      "no-underscore-dangle": 0,
      "react/display-name": 0,
      "react/jsx-quotes": 1,
      "react/jsx-no-undef": 1,
      "react/jsx-sort-props": 1,
      "react/jsx-uses-react": 1,
      "react/jsx-uses-vars": 1,
      "react/no-did-mount-set-state": 1,
      "react/no-did-update-set-state": 1,
      "react/no-multi-comp": 1,
      "react/no-unknown-property": 1,
      "react/prop-types": 1,
      "react/react-in-jsx-scope": 1,
      "react/self-closing-comp": 1,
      "react/wrap-multilines": 1
    }
  }
}

Edited

error occur in mockhelper.js in mockPlayer function here is that file code

    import _ from 'lodash';

import * as stoneHelpers from 'utils/stoneTestHelpers';

import { StoneColor,
         SequenceType } from 'constants/AppConstants';

export function mockStone(color = StoneColor.RED, number = 1) {
  return {
    number: number,
    color: color
  };
}

export function mockOkeyStoneWithHelper(okeyStone, helper) {
  return _.extend({}, okeyStone, {
    isOkey: true,
    okeyHelper: helper
  });
}

export function mockStoneWithId(color = StoneColor.RED, number= 1, id) {
  return {
    id: id,
    color: color,
    number: number
  };
}

export function mockPlayer(id, name) {
  return {
    id: id,
    name: name
  };
}

export function mockTable() {
  return {
    players: [
      mockPlayer(1, 'mockPlayer1'),
      mockPlayer(2, 'mockPlayer2'),
      mockPlayer(3, 'mockPlayer3'),
      mockPlayer(4, 'mockPlayer4')
    ],
    scoreboard: []
  };
}

export function mockOpenStoneGroups(owner) {
  return {
    groups: [stoneHelpers.buildStoneGroupSequenceWithStones(
      SequenceType.RAINBOW,
      stoneHelpers.buildStoneRainbow(5, 0),
      owner),
     stoneHelpers.buildStoneGroupSequenceWithStones(
       SequenceType.SAME_COLOR,
       stoneHelpers.buildStoneSameColor(6, StoneColor.GREEN, 300, 4),
       owner)
    ]
  };
}

export function mockOpenStoneGroupsWithGroups(groups) {
  return {
    groups: groups
  };
}

export function mockOpenStoneGroupsForPairs(owner, count) {
  const groups = [];

  while (count-- > 0) {
    groups.push(stoneHelpers.buildStoneGroupPairsWithStones(
      stoneHelpers.buildStonePair(count, StoneColor.RED, count * 100),
      owner
    ));
  }

  return mockOpenStoneGroupsWithGroups(groups);
}

export function mockStartInfo(currentTurn = 0) {
  return {
    stones: _.flatten([
      stoneHelpers.buildStoneSameColor(1, StoneColor.RED, 0, 3),
      stoneHelpers.buildStoneRainbow(13, 300),
      stoneHelpers.buildFreeStoneGroup(400)
    ]),
    discardStones: [
      [stoneHelpers.buildStone(1, StoneColor.RED)],
      [stoneHelpers.buildStone(2, StoneColor.BLACK)],
      [stoneHelpers.buildStone(3, StoneColor.GREEN)],
      [stoneHelpers.buildStone(4, StoneColor.BLUE)]
    ],
    gosterge: stoneHelpers.buildStone(10, StoneColor.BLACK),
    currentTurn: currentTurn
  };
}

export function mockPlayer(id, name, optional) {
  return _.extend({
    id: id,
    name: name
  }, {}, optional);
}

export function mockPlayerFull(id, name) {
  return mockPlayer(id, name, {
    state: {
      turnPoints: 10,
      openPoints: 100,
      openedHands: 0,
      hasOpenedPairs: false
    },
    timeLeft: 10
  });
}

export function mockTable(p1 = mockPlayerFull(1, 'mockPlayer1'),
                          p2 = mockPlayerFull(2, 'mockPlayer2'),
                          p3 = mockPlayerFull(3, 'mockPlayer3'),
                          p4 = mockPlayerFull(4, 'mockPlayer4')) {
  var result = {
    players: [
      p1,
      p2,
      p3,
      p4
    ]
  };
  return result;
}

export function mockMatchStats(ranking, player,
                               score, xp, hands,
                               punish, chips) {
  return {
    player: player,
    stats: {
      ranking: ranking,
      score: score,
      gainedXP: xp,
      openedHands: hands,
      punishment: punish,
      gainedChips: chips
    }
  };
}

export function mockMatchResult(p1 = mockPlayerFull(1, 'mockPlayer'),
                                p2 = mockPlayerFull(2, 'mockPlayer2'),
                                p3 = mockPlayerFull(3, 'mockPlayer3'),
                                p4 = mockPlayerFull(4, 'mockPlayer4')) {
  return {
    rankings: [
      mockMatchStats(1, p1, 100, 50, 2, 1, 400),
      mockMatchStats(2, p2, 50, 25, 1, 1, 200),
      mockMatchStats(3, p3, 25, 10, 1, 0, -100),
      mockMatchStats(4, p4, 10, 10, 1, 3, -200)
    ]
  };
}

export function mockInitialStateGamePlay() {
  return {
    discardStones: [[], [], [], []],
    sequence: [],
    pairs: [],
    selectedStone: null
  };
}
1

There are 1 answers

4
loganfsmyth On BEST ANSWER

The error you posted

has already been exported. Exported identifiers must be unique.

may not be clear enough if you don't already know what is wrong. To break it down

Exported identifiers must be unique.

is saying that a file can only export one thing with a certain name. In your specific code you have both

export function mockTable(
    p1 = mockPlayerFull(1, 'mockPlayer1'),
    p2 = mockPlayerFull(2, 'mockPlayer2'),
    p3 = mockPlayerFull(3, 'mockPlayer3'),
    p4 = mockPlayerFull(4, 'mockPlayer4')
) {
    // ...
}

and

export function mockTable() {
  return {
    players: [
      mockPlayer(1, 'mockPlayer1'),
      mockPlayer(2, 'mockPlayer2'),
      mockPlayer(3, 'mockPlayer3'),
      mockPlayer(4, 'mockPlayer4')
    ],
    scoreboard: []
  };
}

which doesn't make sense. You can't have two functions in the same scope with the same name.