ctimmerm / axios-mock-adapter

Axios adapter that allows to easily mock requests
MIT License
3.47k stars 245 forks source link

Cannot find module 'axios-mock-adapter' or its corresponding type declarations.ts #354

Closed seda1094 closed 1 year ago

seda1094 commented 1 year ago

I am getting an error about the type declaration :(( Cannot find module 'axios-mock-adapter' or its corresponding type declarations.ts

Here are my versions

{
  "name": "control-center-ui",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@emotion/react": "^11.9.3",
    "@emotion/styled": "^11.9.3",
    "@mui/icons-material": "^5.8.4",
    "@mui/lab": "^5.0.0-alpha.91",
    "@mui/material": "^5.9.1",
    "@react-oauth/google": "^0.2.6",
    "@reduxjs/toolkit": "^1.8.3",
    "@sentry/react": "^7.7.0",
    "@sentry/tracing": "^7.7.0",
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.3.0",
    "@testing-library/user-event": "^14.3.0",
    "@types/jest": "^28.1.6",
    "@types/node": "^18.0.6",
    "@types/nprogress": "^0.2.0",
    "@types/react": "^18.0.15",
    "@types/react-dom": "^18.0.6",
    "axios": "^0.27.2",
    "broadcast-channel": "^4.14.0",
    "lint-staged": "^13.0.3",
    "nprogress": "^0.2.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-hook-form": "^7.33.1",
    "react-redux": "^8.0.2",
    "react-router-dom": "^6.3.0",
    "react-scripts": "^5.0.1",
    "recaptcha-v3": "^1.10.0",
    "redux": "^4.2.0",
    "redux-persist": "^6.0.0",
    "redux-persist-transform-expire-in": "^1.1.0",
    "typescript": "^4.7.4",
    "web-vitals": "^2.1.4",
    "workbox-background-sync": "^6.5.3",
    "workbox-broadcast-update": "^6.5.3",
    "workbox-cacheable-response": "^6.5.3",
    "workbox-core": "^6.5.3",
    "workbox-expiration": "^6.5.3",
    "workbox-google-analytics": "^6.5.3",
    "workbox-navigation-preload": "^6.5.3",
    "workbox-precaching": "^6.5.3",
    "workbox-range-requests": "^6.5.3",
    "workbox-routing": "^6.5.3",
    "workbox-strategies": "^6.5.3",
    "workbox-streams": "^6.5.3"
  },

  "devDependencies": {
    "@types/react-test-renderer": "^18.0.0",
    "@types/redux-logger": "^3.0.9",
    "@types/redux-mock-store": "^1.0.3",
    "@typescript-eslint/eslint-plugin": "^5.30.7",
    "@typescript-eslint/parser": "^5.30.7",
    "axios-mock-adapter": "^1.21.1",
    "eslint": "^8.20.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-prettier": "^4.2.1",
    "eslint-plugin-react": "^7.30.1",
    "eslint-plugin-react-hooks": "^4.6.0",
    "husky": "^8.0.1",
    "prettier": "^2.7.1",
    "redux-mock-store": "^1.5.4",
    "yarn-upgrade-all": "^0.7.1"
  }
}

Thanks.

sarvold commented 1 year ago

This is not a solution but might help others. I guess in your case it was missing an npm install. Sort of somewhat similar issue here, but on version 1.21.4 . I got Cannot find module 'axios-mock-adapter/types' from 'myfolder/myfile.service.spec.ts' because of an auto-import for MockAdapter. The difference in my case was that for some reason I was importing it from /types, and clearly there is no such module. Fixed it by manually changing the import to be from 'axios-mock-adapter'.