Sep*_*eed 2 typescript ts-node
ts-node 给我这个错误:
找不到模块“process”或其相应的类型声明。
这是我的 tsconfig.json
{
"compilerOptions": {
"types": [ "node "],
"declaration": true,
"target": "ESNext",
"module": "CommonJS",
"outDir": "./dist",
"rootDir": "./src",
"moduleResolution": "node"
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的 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"
}
}
Run Code Online (Sandbox Code Playgroud)
为什么我会收到此错误?
如此愚蠢。上面有一个空格"types": [ "node "],。
另外,如果您像这样导入,您只会收到我列出的错误:
import { argv } from 'process';
Run Code Online (Sandbox Code Playgroud)
如果您仅使用变量而不使用 import 语句,则会出现错误:
找不到名称“进程”。您需要为节点安装类型定义吗?尝试
npm i --save-dev @types/node然后添加node到 tsconfig 中的 types 字段。
为了便于搜索,我将不删除这个问题。我真的找不到其他地方列出的这个错误。
| 归档时间: |
|
| 查看次数: |
9154 次 |
| 最近记录: |