0

I need to add a map to my app (Nextjs, React, Typescript) that receives latitude and longitude and shows it with a marker.

I did yarn add -D @types/google.maps

It should be okay, but when I'm importing it to my Map component from 'google-maps-react', it says "Cannot find module 'google-maps-react' or its corresponding type declarations."

I look at my node_modules files and there is the google maps carpet and it's types.

Has anybody gone through this? I think it's a problem related to typescript.

This is my package.json:

  "name": "wtw-website",
  "author": "Wheel The World Engineering Team <[email protected]>",
  "description": "Wheel The World Website, April 2021",
  "version": "1.0.0",
  "scripts": {
    "dev": "next",
    "build": "next build",
    "start": "next start",
    "lint": "eslint '*/**/*.{ts,tsx}' --quiet --fix",
    "export": "next export",
    "pre-deploy": "eslint '*/**/*.{ts,tsx}' --quiet --fix && next build && next export",
    "test": "jest --verbose",
    "test:watch": "jest --verbose --watch",
    "test:cov": "jest --collectCoverage"
  },
  "dependencies": {
    "@chakra-ui/icons": "^1.0.5",
    "@chakra-ui/react": "^1.3.3",
    "@chakra-ui/system": "^1.3.1",
    "@chakra-ui/theme-tools": "1.0.4",
    "@emotion/react": "11.1.5",
    "@emotion/styled": "11.1.5",
    "framer-motion": "^3.5.2",
    "next": "latest",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-redux": "^7.2.2",
    "redux": "^4.0.5",
    "redux-devtools-extension": "^2.13.8",
    "redux-thunk": "^2.3.0",
    "sass": "^1.32.8",
    "wtw-icons": "1.2.4"
  },
  "devDependencies": {
    "@babel/core": "^7.13.1",
    "@babel/eslint-parser": "^7.13.4",
    "@testing-library/jest-dom": "^5.11.9",
    "@testing-library/react": "^11.2.5",
    "@types/google.maps": "^3.44.2",
    "@types/node": "^14.6.0",
    "@types/react": "^16.9.46",
    "@types/react-dom": "^16.9.8",
    "@types/react-redux": "^7.1.16",
    "@types/redux-mock-store": "^1.0.2",
    "@typescript-eslint/eslint-plugin": "^4.15.2",
    "@typescript-eslint/parser": "^4.15.2",
    "babel-eslint": "^10.1.0",
    "babel-jest": "^26.6.3",
    "babel-plugin-module-resolver": "^4.1.0",
    "eslint": "^7.20.0",
    "eslint-config-airbnb": "^18.2.1",
    "eslint-config-prettier": "^8.1.0",
    "eslint-import-resolver-babel-module": "^5.2.0",
    "eslint-plugin-html": "^6.1.1",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-prettier": "^3.3.1",
    "eslint-plugin-react": "^7.22.0",
    "eslint-plugin-react-hooks": "^4.2.0",
    "jest": "^26.6.3",
    "prettier": "^2.2.1",
    "redux-mock-store": "^1.5.4",
    "typescript": "4.0.5"
  },
  "license": "MIT"
}

enter image description here

2
  • Can you please post your package.json file and also list your folder structure? Commented Mar 4, 2021 at 22:47
  • I added them to the question! :) Commented Mar 4, 2021 at 22:51

1 Answer 1

1

From your package.json file it seems that you don't have google-maps-react installed.

Run npm i --save google-maps-react or yarn add google-maps-react in your terminal in your project folder to install it.

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.