简体   繁体   English

TS2307:找不到模块“@/*”或其对应的类型声明

[英]TS2307: Cannot find module '@/*' or its corresponding type declarations

For whatever strange reason my ts webpack project was unable to resolve all my custom paths today.出于某种奇怪的原因,我的 ts webpack 项目今天无法解析我所有的自定义路径。 Whatever I try fails.无论我尝试什么都失败了。 I re-installed every package changed many settings but it still fails to load all paths and show the error above for all files.我重新安装了每个软件包,更改了许多设置,但它仍然无法加载所有路径并显示所有文件的上述错误。

I made sure my ts-config "moduleResolution": "node" is properly set.我确保我的 ts-config "moduleResolution": "node"设置正确。

ts-config.json ts-config.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "CommonJS",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "allowJs": true,
    "noImplicitAny": false,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost",
      "es2016",
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "tests/**/*.ts",
    "tests/**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}

package.json包.json

{
  "scripts": {
    "test": "exit 0;",
    "build": "cross-env NODE_ENV=production webpack",
    "serve": "cross-env NODE_ENV=development webpack serve"
  },
  "devDependencies": {
    "@babel/core": "^7.8.7",
    "@babel/plugin-proposal-class-properties": "^7.18.6",
    "@babel/plugin-transform-runtime": "^7.5.5",
    "@babel/plugin-transform-typescript": "^7.18.6",
    "@babel/preset-env": "^7.5.5",
    "@babel/preset-es2015": "^7.0.0-beta.53",
    "@types/google.maps": "^3.49.2",
    "@types/jquery": "^3.5.14",
    "@types/select2": "^4.0.55",
    "@webpack-cli/serve": "^1.1.0",
    "babel-loader": "^8.0.6",
    "babel-preset-vue": "^2.0.2",
    "clean-webpack-plugin": "^3.0.0",
    "cross-env": "^5.2.0",
    "css-loader": "^5.1.1",
    "eslint": "^6.1.0",
    "eslint-config-prettier": "^6.0.0",
    "eslint-plugin-prettier": "^3.1.0",
    "prettier": "^1.18.2",
    "style-loader": "^2.0.0",
    "ts-loader": "^9.3.1",
    "typescript": "^4.7.4",
    "uglifyjs-webpack-plugin": "^2.2.0",
    "vue": "^2.7.0",
    "vue-html-loader": "^1.2.4",
    "vue-loader": "^15.7.1",
    "vue-style-loader": "^4.1.2",
    "vue-template-compiler": "^2.6.10",
    "vuex": "^3.1.1",
    "webpack": "^5.5.1",
    "webpack-bundle-analyzer": "^4.6.1",
    "webpack-cli": "^4.2.0",
    "webpack-dev-server": "^4.0.0-beta.1"
  },
  "peerDependencies": {
    "vue": "^2.6.10"
  },
  "dependencies": {
    "accounting-js": "^1.1.1",
    "aos": "michalsnik/aos",
    "axios": "^0.19.0",
    "babel-preset-es2015": "^6.24.1",
    "core-js": "^3.8.0",
    "flatpickr": "^4.6.9",
    "google-maps": "^4.3.3",
    "jquery": "^3.4.1",
    "macy": "^2.5.1",
    "moment": "^2.24.0",
    "moment-locales-webpack-plugin": "^1.2.0",
    "moment-timezone": "^0.5.33",
    "moment-timezone-data-webpack-plugin": "^1.5.0",
    "select2": "^4.0.12",
    "snapsvg-cjs": "^0.0.6",
    "swiper": "^6.3.5",
    "webpack-env": "^0.8.0"
  }
}

Can you think of any other reason why it might be unable to find all paths suddenly?你能想到它可能突然找不到所有路径的任何其他原因吗? I can even reset my git status to weeks ago and install all packages from when it definitely worked but it still fails.我什至可以将我的 git 状态重置为几周前,并从它确实有效但仍然失败的时候开始安装所有软件包。

I think the paths should be like this:我认为路径应该是这样的:

    "paths": {
      "@*": [
        "src/*"
      ]
    }

Without slash "@*"没有斜杠“@*”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误 TS2307:找不到模块“fs”或其相应的类型声明 - error TS2307: Cannot find module 'fs' or its corresponding type declarations TS2307:找不到模块 '_rc-trigger@5.2.0@rc-trigger' 或其对应的类型声明 - TS2307: Cannot find module '_rc-trigger@5.2.0@rc-trigger' or its corresponding type declarations 错误 TS2307:找不到模块 '.shaders/vertex.glsl' 或其对应的类型声明 - error TS2307: Cannot find module '.shaders/vertex.glsl' or its corresponding type declarations TS2307 错误:找不到模块“../constants”或其相应的类型声明 - TS2307 Error: Cannot find module '../constants' or its corresponding type declarations React,Storybook - TS2307:找不到模块“按钮”或其相应的类型声明 CAN SB RESOLVE? - React,Storybook - TS2307: Cannot find module 'Button' or its corresponding type declarations CAN SB RESOLVE? 错误 TS2307:找不到模块或其对应的类型声明。 在 Github 操作 - error TS2307: Cannot find module or its corresponding type declarations. on Github Actions TS2307:找不到模块“./App.vue”或其相应的类型声明 - TS2307: Cannot find module './App.vue' or its corresponding type declarations 业力,Webpack & Typescript:TS2307:找不到模块“log4js”或其相应的类型声明 - Karma, Webpack & Typescript: TS2307: Cannot find module 'log4js' or its corresponding type declarations src/index.ts:12:22 - 错误 TS2307:找不到模块“./schema.graphql”或其相应的类型声明 - src/index.ts:12:22 - error TS2307: Cannot find module './schema.graphql' or its corresponding type declarations 错误 TS2307:找不到模块“路径”或其相应的类型声明。 尝试使用 Knex 在 heroku 应用程序中迁移时 - error TS2307: Cannot find module 'path' or its corresponding type declarations. when trying to migrate in heroku app with Knex
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM