ts-node is giving me this error:
Cannot find module 'process' or its corresponding type declarations.
This is my tsconfig.json
{
"compilerOptions": {
"types": [ "node "],
"declaration": true,
"target": "ESNext",
"module": "CommonJS",
"outDir": "./dist",
"rootDir": "./src",
"moduleResolution": "node"
}
}
This is my 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"
}
}
Why am I getting this error?
So dumb. There's a space in "types": [ "node "],
above.
Also, you only get the error I listed if you import like this:
import { argv } from 'process';
If you just use the variable without an import statement, you get the error:
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.
I'm going to leave this question un-deleted for searchability sake. I really couldn't find this error listed anywhere else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With