Cannot find module or its corresponding type declarations - react typescript craco

488 Views Asked by At

Its very basic problem but not work... I created fresh create-react-app and installed craco for relatives paths, but vsCode still give me error during imports.

craco.config.js

const path = require('path');
module.exports = {
  webpack: {
    alias: {
      '@': path.resolve(__dirname, 'src/'),
      '@components/*': path.resolve(__dirname, 'src/components'),
      '@views/*': path.resolve(__dirname, 'src/views')
    }
  },
  jest: {
    configure: {
      moduleNameMapper: {
        '^@(.*)$': '<rootDir>/src$1'
      }
    }
  }
};

tsconfig.json

[{
  "compilerOptions": {
    "baseUrl": "./",
    "target": "es5",
    "lib": \[
      "dom",
      "dom.iterable",
      "esnext"
    \],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": \[
    "src"
  \],
  "paths": {
    "@components/*": \["src/components/*"\],
    "@views/*": \["src/views/*"\]
  }
}][1]

I think that i did everything correctly... but it still not working. Please help [1]: https://i.stack.imgur.com/8I7CB.png

0

There are 0 best solutions below