小编Acu*_*vov的帖子

无法使用 typeScript 找到模块“mongoose”

我想在顶级函数中使用 wait,为此,typeScript 要求我将 tsconfig.json 中的目标语言设置为 2017 或更高版本,并将模块设置为 es2022。但是当我这样做时,出现以下错误:“找不到模块‘mongoose’。您的意思是将‘moduleResolution’选项设置为‘node’,还是将别名添加到‘paths’选项?”

我已经在很多地方进行了搜索,但没有找到解决方案。

这是我的一些代码:

tsconfig.json

{
"compilerOptions": {
 "target": "es2022",   
"module": "es2022",
"outDir": "./build",     
"esModuleInterop": true,   
 "forceConsistentCasingInFileNames": true,
 "strict": true,  
"skipLibCheck": true 
}
}
Run Code Online (Sandbox Code Playgroud)

包.json

{
  "name": "finanzas",
  "version": "1.0.0",
  "description": "API que permite gestionar las finanzas de un nucleo familiar o individuo",
  "main": "index.js",
  "scripts": {
    "dev": "ts-node-dev src/index.ts",
    "start": "node build/index.js",
    "tsc": "tsc",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "Andres Felipe Cuervo",
  "license": "ISC",
  "devDependencies": …
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb node.js typescript

3
推荐指数
1
解决办法
2805
查看次数

标签 统计

mongodb ×1

mongoose ×1

node.js ×1

typescript ×1