node.js - 无法在节点项目上导入 *d.ts
问题描述
我有以下代码结构:
src
├── config
│ └── index.ts
├── db
│ ├── index.ts
│ └── Schema.json
├── graphql
│ ├── resolvers.ts
│ └── schema.graphql
├── index.ts
└── models
├── graphql.d.ts
└── index.d.ts
问题是当尝试使用以下代码在 resolvers.ts 上导入模式时会发生什么:
import {IPhoto} from '../models'
我得到以下选项:
错误:找不到模块“../models”
tsconfig.json 如下:
{
"compilerOptions": {
"outDir": "./build",
"allowJs": true,
"target": "es2019",
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"*": ["node_modules/*"]
}
},
"include": ["src/**/*", "src/scripts", "package.json", "types/**/*", "src/scripts/**/*"],
"exclude": [
".cache",
"acceptance-tests",
"build",
"coverage",
"jest.config.js",
"jest",
"node_modules"
]
}
为了启动它,我使用以下脚本:
"dev": "env-cmd tsnd --respawn src/index.ts",
我该如何解决这个问题?
谢谢
解决方案
推荐阅读
- python - 如何使嵌套列表表现得像 numpy 数组?
- python - Python电报机器人 - AttributeError:'sqlite3.Cursor'对象没有属性'data_filter'
- java - Java NIO解码过程中如何去掉不正确的符号?
- android - Nativescript Angular-“typeof View”类型上不存在属性“SYSTEM_UI_FLAG_IMMERSIVE_STICKY”
- sockets - 具有相同本地地址的套接字能否同时处于两种状态“LISTEN”和“ESTABLISHED”
- c# - 使用 C# 访问 JSON 正文
- sql - Oracle SQL - 插入到选择语句中 - 错误
- typescript - 为什么打字稿在移相器中找不到这些方法?
- javascript - 如何推入ajax?
- sql - SQL BigQuery 在使用案例时花费太多时间然后获取列