@ types / node installed typescript version cannot find module "child_process"
I found the typescript version for node , unfortunately it couldn't find the "child_process" module from the node packages.
Exactly the error message on my console Module not found: Error: Cannot resolve 'child_process'
When I looked at some blog they recommended adding below code in tsconfig.json file .
"typeRoots": [
"node_modules/@types"
]
The same thing that I pasted here hardly did not help.
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2016",
"dom"
]
}
}
Why don't they introduce this node module? Am I doing something wrong in the tsconfig.json file? I would appreciate it if you could help a little. Thanks in advance.
source to share
Maybe the way is:
"typeRoots": [
"../node_modules/@types"
]
You usually have tsconfig in src
.
Update:
My original answer doesn't make sense because you have it "baseUrl": "src"
.
Instead, I believe it might be a Webpack issue.
Try adding this to your webpack.config file :
target: 'node'
Update 2:
Workaround: add the following to the config file:
node: {
child_process: 'empty'
}
source to share