2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

「Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.」の解決方法

2
Posted at

はじめに

TypeScriptで開発をしていたらエラーが発生しました。

前提

  • TypeScript:7.0.2

問題

Cannot find name 'process'. 
Do you need to install type definitions for node? 
Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.

解決方法

1. nodeの型をインストール

npm i --save-dev @types/node

2. tsconfig.jsonを更新

tsconfig.json
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "outDir": "./dist",
    "rootDir": "./src",
    "strict": true,
+   "types": ["node"]
  },
  "include": ["src"]
}

おわりに

今回型はインストールされてましたが、tsconfigに追加されてなかったためエラーが出ていました。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?