NodeJS Typescript停止使用绝对路径

sg3maiej  于 2022-12-18  发布在  Node.js
关注(0)|答案(1)|浏览(129)

我正在维护一个存储库的分支,在我上次更新时我应用了一些更改,但是现在typescript不能识别绝对路径。
我没有对tsconfig.json进行任何更改:

{
  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "alwaysStrict": true,
    "baseUrl": "src",
    "downlevelIteration": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "isolatedModules": true,
    "jsx": "react-jsx",
    "lib": ["dom", "dom.iterable", "esnext"],
    "module": "esnext",
    "moduleResolution": "node",
    "noEmit": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noUnusedLocals": false,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "strict": true,
    "strictNullChecks": true,
    "target": "es5",
    "types": ["jest", "node"],
    "useUnknownInCatchVariables": false
  },
  "exclude": ["node_modules", "cypress"],
  "include": ["src/**/*"]
}

但是现在编译器无法识别如下所示的路径:

import { useIsDarkMode } from 'state/user/hooks'
sczxawaw

sczxawaw1#

在我删除node_modules并调用

yarn clean cache
yarn

然后一切又开始运转了

相关问题