kinotto / geonames.js

Nodejs and Browser client for Geonames.org REST API :earth_africa:
http://www.geonames.org/export/client-libraries.html
MIT License
88 stars 17 forks source link

You may need an appropriate loader to handle this file type #11

Closed pdhung197 closed 5 years ago

pdhung197 commented 5 years ago

I use Geonames for my React project, my package.json dependencies:

"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",
    "geonames.js": "^2.3.0",
    "isomorphic-fetch": "^2.2.1",
    "jquery": "^3.1.1",
    "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.3.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.3.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"
  }

And I import to my jsx files: import Geonames from 'geonames.js'; But I get error:

Failed to compile.

Error in ./~/geonames.js/dist/geonames.min.js
Module parse failed: D:\project\reactclient\node_modules\geonames.js\dist\geonames.min.js Unexpected token (1:2024)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:2024)
 @ ./src/containers/settings/general/Settings/index.js 84:15-37

How can I fix it ?

kinotto commented 5 years ago

Hello @pdhung197 , this issue is most likely related to your webpack config file, you may need to change it to load the correct presets for babel. take a look at this topic on stackOverflow :) https://stackoverflow.com/questions/33469929/you-may-need-an-appropriate-loader-to-handle-this-file-type-with-webpack-and-b