catamphetamine / libphonenumber-js

A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript
https://catamphetamine.gitlab.io/libphonenumber-js/
MIT License
2.77k stars 217 forks source link

Uncaught SyntaxError: Unexpected token export #336

Closed pdhung197 closed 4 years ago

pdhung197 commented 5 years ago

I have a reactjs project. Now I installed libphonenumber-js library to project.
When I run project, I got an error: Uncaught SyntaxError: Unexpected token export, and page doesn't load.
How can I fix this issues?

issues

This my pagkage.json content:

  "name": "my-app",
  "version": "4.6.3302",
  "private": true,
  "dependencies": {
    "bluebird": "^3.5.1",
    "bootstrap": "^3.3.7",
    "chart.js": "^2.7.2",
    "classnames": "^2.2.5",
    "convert-units": "^2.3.4",
    "currency-formatter": "^1.3.1",
    "file-saver": "^1.3.3",
    "fixed-data-table-2": "^0.8.15",
    "font-awesome": "^4.7.0",
    "isomorphic-fetch": "^2.2.1",
    "jquery": "^3.1.1",
    "libphonenumber-js": "^1.7.22",
    "lodash": "^4.17.4",
    "moment": "^2.19.2",
    "moment-range": "^3.0.3",
    "moment-timezone": "^0.5.14",
    "object-assign": "^4.1.1",
    "prop-types": "^15.6.0",
    "query-string": "^5.0.1",
    "react": "^16.9.0",
    "react-addons-css-transition-group": "^15.6.2",
    "react-autosuggest": "^9.3.2",
    "react-bootstrap": "^0.31.5",
    "react-bootstrap-timezone-picker": "^1.0.12",
    "react-chartjs-2": "^2.7.4",
    "react-country-region-selector": "^1.2.3",
    "react-datetime": "^2.11.0",
    "react-dom": "^16.9.0",
    "react-dom-factories": "^1.0.2",
    "react-flag-icon-css": "^1.0.23",
    "react-google-maps": "^9.4.3",
    "react-helmet": "^5.2.0",
    "react-hotkeys": "^0.10.0",
    "react-input-autosize": "^2.1.2",
    "react-intl-tel-input": "^5.0.7",
    "react-jss": "^8.4.0",
    "react-moment": "^0.6.8",
    "react-notifications": "^1.3.0",
    "react-onclickoutside": "^6.7.0",
    "react-overlays": "^0.8.3",
    "react-redux": "^5.0.3",
    "react-redux-i18n": "^1.9.1",
    "react-router": "^3.2.0",
    "react-router-redux": "^4.0.8",
    "react-script-loader": "0.0.1",
    "react-select": "^1.0.0-rc.10",
    "react-spinners": "^0.3.2",
    "react-style-proptype": "^3.1.0",
    "react-timeago": "^3.3.0",
    "react-transition-group": "^2.3.1",
    "redux": "^3.6.0",
    "redux-logger": "^2.8.2",
    "redux-thunk": "^2.2.0",
    "shallowequal": "^1.0.2",
    "socket.io": "1.7.3",
    "socket.io-client": "1.7.3",
    "toetag": "^3.3.7",
    "underscore.deferred": "^0.4.0",
    "uuid": "^3.1.0"
  },
  "devDependencies": {
    "babel-eslint": "^10.0.1",
    "case-sensitive-paths-webpack-plugin": "^2.0.0",
    "babel-plugin-import": "^1.6.5",
    "babel-plugin-module-resolver": "^3.1.0",
    "babel-plugin-styled-components": "^1.8.0",
    "babel-plugin-wrap-in-js": "^1.1.1",
    "eslint": "^5.7.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-config-prettier": "^3.1.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.1.2",
    "eslint-plugin-prettier": "^3.0.0",
    "eslint-plugin-react": "^7.11.1",
    "eslint-plugin-react-hooks": "^1.5.0",
    "node-sass-chokidar": "^1.3.3",
    "npm-run-all": "^4.1.3",
    "prettier": "^1.16.4",
    "react-scripts": "0.9.4"
  },
  "scripts": {
    "build-css": "node-sass-chokidar src/ -o src/",
    "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive --usePolling --polling-interval 500",
    "start-js": "react-scripts start",
    "start": "npm-run-all -p watch-css start-js",
    "build-js": "react-scripts build",
    "build": "npm-run-all build-css build-js",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}
catamphetamine commented 5 years ago

Seems that your bundler is including metadata.min.json.js instead of metadata.min.json for some reason. That's most likely a bug in the bundler you're using.

pdhung197 commented 5 years ago

Seems that your bundler is including metadata.min.json.js instead of metadata.min.json for some reason. That's most likely a bug in the bundler you're using.

@catamphetamine Thank you so much. So, how to check and fix it? All setting of project is default and I don't know how to change config to build bundler.js file.

Achyuth-India commented 4 years ago

I am also facing the same issue. @pdhung197 did you able to solve this issue ?

catamphetamine commented 4 years ago

I don't see a lot of " 👍 " on this issue. Only two people have had it in half a year. I guess I should close it for now. It can be reopened in future.