typescript - ts-node 错误:找不到模块“进程”或其相应的类型声明
问题描述
ts-node 给了我这个错误:
找不到模块“进程”或其相应的类型声明。
这是我的 tsconfig.json
{
"compilerOptions": {
"types": [ "node "],
"declaration": true,
"target": "ESNext",
"module": "CommonJS",
"outDir": "./dist",
"rootDir": "./src",
"moduleResolution": "node"
}
}
这是我的 package.json
{
"name": "example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"author": "Seph Reed",
"license": "ISC",
"devDependencies": {
"@types/node": "^14.14.9",
"ts-node": "^9.0.0",
"typescript": "^4.1.2"
}
}
为什么我会收到此错误?
解决方案
如此愚蠢。上面有空位"types": [ "node "],
。
此外,如果您像这样导入,您只会收到我列出的错误:
import { argv } from 'process';
如果你只使用没有 import 语句的变量,你会得到错误:
找不到名称“进程”。您需要为节点安装类型定义吗?尝试
npm i --save-dev @types/node
然后添加node
到 tsconfig.xml 中的类型字段。
为了便于搜索,我将不删除这个问题。我真的找不到在其他任何地方列出的这个错误。
推荐阅读
- python - 在 S3 中压缩文件
- go - 当 xerrors.Errorf() 输出错误时,有什么方法可以设置 xerrors.Caller(1)?
- ios - 根据屏幕尺寸翻译/缩放 UIImageViews
- c - 在C中将度数转换为弧度时结果令人困惑
- angular - 点击后永久禁用按钮
- sql - 无法在 oracle SQL 开发人员中更新内部 if 条件
- azure - 在云中托管 Azure IoT-HuB 设备客户端
- bash - shell - 将命令行参数传递给 bash 脚本不起作用
- python - Python 的 Stacktrace 在 psycopg2 connection.notices 中被截断
- regex - 注释行与 Ansible 匹配一些模式和后面的 n 个字符串