ts-node 错误:找不到模块“process”或其对应的类型声明
2020-11-25
10520
ts-node 给出了此错误:
Cannot find module 'process' or its corresponding type declarations.
这是我的 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"
}
}
为什么我会收到此错误?
1个回答
太蠢了。上面的
"types": [ "node "],
中有一个空格。
此外,如果您像这样导入,则只会收到我列出的错误:
import { argv } from 'process';
如果您只使用变量而不使用导入语句,则会收到错误:
Cannot find name 'process'. Do you need to install type definitions for node? Try
npm i --save-dev @types/node
and then addnode
to the types field in your tsconfig.
为了便于搜索,我将保留此问题不予删除。我真的无法在其他任何地方找到此错误。
Seph Reed
2020-11-25