【问题标题】:Cannot find module '@nestjs/core' or its corresponding type declarations找不到模块“@nestjs/core”或其相应的类型声明
【发布时间】:2022-02-06 22:42:05
【问题描述】:

几周前,我在计算机上全局安装了 NestJS。 现在我又回到了这个话题,开始学习。

所以我用命令创建了新项目:

nest new ./

它生成了所有文件,但是当我尝试使用命令运行此应用程序时:

nest start

我希望这个模板项目能够启动,但导入路径有错误? 这是由于我安装的 Nest 版本还是其他原因?

屏幕上的错误:

我的巢的版本: 7.5.6

包.json:

  "dependencies": {
    "@nestjs/common": "^7.6.13",
    "@nestjs/core": "^7.6.13",
    "@nestjs/platform-express": "^7.6.13",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^6.6.6"
  },
  "devDependencies": {
    "@nestjs/cli": "^7.5.6",
    "@nestjs/schematics": "^7.2.7",
    "@nestjs/testing": "^7.6.13",
    "@types/express": "^4.17.11",
    "@types/jest": "^26.0.20",
    "@types/node": "^14.14.31",
    "@types/supertest": "^2.0.10",
    "@typescript-eslint/eslint-plugin": "^4.15.2",
    "@typescript-eslint/parser": "^4.15.2",
    "eslint": "^7.20.0",
    "eslint-config-prettier": "^8.1.0",
    "eslint-plugin-prettier": "^3.3.1",
    "jest": "^26.6.3",
    "prettier": "^2.2.1",
    "supertest": "^6.1.3",
    "ts-jest": "^26.5.2",
    "ts-loader": "^8.0.17",
    "ts-node": "^9.1.1",
    "tsconfig-paths": "^3.9.0",
    "typescript": "^4.1.5"
  },

【问题讨论】:

  • nest new 应该为您安装依赖项。但以防万一,你能运行你选择的包管理器的安装命令吗?
  • @JayMcDoniel 我运行了npm install 并且花了一些时间,所以nest new 没有安装所有需要的依赖项。在该应用程序正常启动后,谢谢! :)

标签: nestjs


【解决方案1】:

我有同样的问题。以下两个命令修复了它:

npm install @nestjs/common
npm install @nestjs/core

这些命令可确保您使用的是这些软件包的最新版本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-05
    • 2022-12-16
    • 2020-11-04
    • 2023-01-31
    • 2020-10-19
    • 2021-09-21
    • 2020-12-23
    • 2020-08-16
    相关资源
    最近更新 更多